零开销抽象

This commit is contained in:
2026-08-07 16:51:40 +08:00
parent 1e903dfe1e
commit 1ddd2799f2
8 changed files with 164 additions and 46 deletions
+2 -2
View File
@@ -407,7 +407,7 @@ auto policy = property_synchronization<Device>(
);
```
The schema remains the same; only the instance lock topology changes.
The schema remains the same; only that instance uses an override lock topology. Default instances share one resolved topology per type, so the default plan is not re-resolved for every object.
## 15. Inspect resolved synchronization
@@ -628,7 +628,7 @@ struct Device : Property_Object<Device, No_Lock_Policy> {
};
```
`No_Lock_Policy` uses `Null_Shared_Mutex`; it removes real mutual exclusion and should only be selected when external ownership guarantees make that correct.
`No_Lock_Policy` uses `Null_Shared_Mutex`; it removes real mutual exclusion and should only be selected when external ownership guarantees make that correct. Its default managed-object path stores no mutex array and performs no per-instance heap allocation for synchronization. A custom `Property_Synchronization` may still allocate a compact override topology because computed-property synchronization-domain checks must preserve the selected per-instance layout.
## 23. Raw object access
+2 -2
View File
@@ -407,7 +407,7 @@ auto policy = property_synchronization<Device>(
);
```
Schema 本身不变,只改变该实例的 lock topology。
Schema 本身不变,只有这个实例使用覆盖后的 lock topology。默认实例按类型共享一份解析结果,因此不会为每个对象重复解析默认同步计划。
## 15. 查看解析后的同步拓扑
@@ -628,7 +628,7 @@ struct Device : Property_Object<Device, No_Lock_Policy> {
};
```
`No_Lock_Policy` 使用 `Null_Shared_Mutex`,它取消真实互斥;只有外部所有权规则能够保证正确性时才应该使用。
`No_Lock_Policy` 使用 `Null_Shared_Mutex`,它取消真实互斥;只有外部所有权规则能够保证正确性时才应该使用。默认 managed-object 路径不保存 mutex 数组,也不会为同步状态产生每实例堆分配。显式使用自定义 `Property_Synchronization` 时仍可能分配一份紧凑覆盖 topology,因为 computed property 的同步域检查必须保留该实例选择的布局。
## 23. Raw Object Access
+4 -3
View File
@@ -72,8 +72,9 @@ This is the structural definition of the type.
`Property_Object<T>` provides:
- resolved lock-slot topology;
- per-instance mutex storage;
- a type-shared resolved default lock-slot topology;
- per-instance mutex storage only when the selected lock policy requires real mutexes;
- a compact per-instance topology only for explicit synchronization overrides;
- managed typed reads and writes;
- capability views;
- static and runtime multi-property guards;
@@ -84,7 +85,7 @@ This is instance behavior, not schema identity.
### 3.3 Design rule
Do not move instance state into the schema, and do not make schema metadata depend on one particular instance-management policy.
Do not move mutable instance synchronization state into the schema, and do not make schema metadata depend on one particular instance-management policy. Immutable topology derived from the type-level default plan may be shared across all instances of that type.
A future user may want to describe a large number of plain objects without paying per-object synchronization cost. The architecture should continue to leave that possibility open.
+4 -3
View File
@@ -72,8 +72,9 @@ Structive 把类型级描述和实例级管理分开。
`Property_Object<T>` 提供:
- 解析后的 lock slot 拓扑;
- 每实例 mutex 存储;
- 同一类型共享的默认解析 lock slot 拓扑;
- 只有真实锁策略才需要的每实例 mutex 存储;
- 只有显式同步覆盖实例才持有的紧凑 topology;
- managed typed read/write
- capability view
- 静态与运行时多属性 guard
@@ -84,7 +85,7 @@ Structive 把类型级描述和实例级管理分开。
### 3.3 设计约束
不要把实例状态塞进 Schema,也不要让 Schema 必须依赖某一种特定的实例管理策略。
不要把可变的实例同步状态塞进 Schema,也不要让 Schema 必须依赖某一种特定的实例管理策略。由类型级默认同步计划推导出的不可变 topology 可以由同类型所有实例共享。
以后完全可能有用户只想描述大量普通对象,却不愿意为每个对象承担同步状态成本。当前架构应该持续保留这种可能性。