Phase 3: owner decisions on RFC 0012 implementation
- spec 04 §40: mutex<T> always linear, never copyable; mutex.take is the only way to dismantle it and needs no live borrow (hence no guard and no waiter); no unlock or destructor - P3-10 (async buffer claims, E4303) moved to P7-10 with task-aware I/O; E4303 stays reserved; Phase 3 scope closed - RFC 0012 erratum: consumption after send is E2002, use is E2001 - tests: take while borrowed (E2101), use after take (E3001)
This commit is contained in:
1 parent
aaf32b6853
commit
929132c81d
8 files changed
+50
-8
No files matched your search
@@ -658,13 +658,15 @@ Decision record: RFC 0012. Depends on `cancellation`. `RwLock` is deferred (rese
|
||||
| Instruction | Operands → result | Effect | Verifier | Runtime |
|
||||
|---|---|---|---|---|
|
||||
| `%m = mutex.make %v` | `T` (consumed) → `mutex<T>` | — | element rules | unlocked; no allocation |
|
||||
| `%v = mutex.take %m` | `mutex<T>` (consumed) → `T` | — | move rules | — |
|
||||
| `%v = mutex.take %m` | `mutex<T>` (consumed) → `T` | — | no live borrow of `%m` (`E2101`; `E4101` if lent to a live task) | returns the contents; no unlock, no destructor |
|
||||
| `mutex.lock %mr, ok -> @ok, cancelled -> @c` (terminator) | `ref<mutex<T>>`; `@ok(guard<T>)`, `@c()` | `task.wait` | the guard is a child of `%mr` (ending `%mr` while it is live is `E2102`); §41 | waiting operation; ready when unlocked; acquire |
|
||||
| `%p = mutex.borrow %g` | `guard<T>` (not consumed) → `mut<T>` | — | child borrow of `%g`, ended before `mutex.unlock %g` (`E2102`) | — |
|
||||
| `mutex.unlock %g` | `guard<T>` (consumed) | — | — | release; all tasks waiting on this mutex become runnable and the first scheduled takes it; a scheduling point |
|
||||
|
||||
No fairness is promised (§32). There is no poisoning and no implicit unlock; an unconsumed guard is `E3002`.
|
||||
|
||||
`mutex<T>` is always linear and never copyable, whatever `T` is; `mutex.take` is the only way to dismantle it. It requires that no borrow of the mutex is live. A guard is a child of the `ref<mutex<T>>` it was locked through (ending that borrow while the guard lives is `E2102`), and a task waiting in `mutex.lock` holds such a borrow, so no guard and no waiter can exist at `mutex.take`. Afterwards the mutex is dead, by the ordinary rules for a dismantled linear value (as after `own.take`): a further use is `E3001` and a further consumption `E2002`.
|
||||
|
||||
## 41. The critical-section rule
|
||||
|
||||
On every path where a `guard<T>` is live, a function MUST NOT execute an instruction that requires the effect `task.wait` or `task.spawn`, nor call a function whose declared effects include `task.wait` or `task.spawn` (`E4304`, `sync.wait_while_locked`, naming the guard and the instruction).
|
||||
|
||||
Reference in new issue
Block a user