Phase 6A: .aji layer 8 (lock and mutexes, select, shields, cancellation)
- lock ref m as x { … } cancelled { … }: mutex.lock on a ref<mutex<T>>
(a mutex is borrowed for the lock, a ref binding used as is); ok edge:
mutex.borrow bound as x; at every normal exit borrow.end x then
mutex.unlock; the guard is never a source value
- mutex.make/mutex.take; mutex<T> type; ref mr = m lends a mutex
- shield { … }: task.shield.begin/end at every exit (nesting by construction)
- task.check_cancel and task.join_cancel as outcome matches
- select: one borrow per endpoint, send values evaluated first and
deduplicated, every edge binds its own value then the unsent values;
bind count E7005, missing outcome E7004
- linear values never get frame storage (borrowed in place)
- liveness: select handled in the read and after walks
- Quick Reference: select edges bind `job` back (ok(x, job), closed(job));
every Quick Reference example now passes (no PENDING)
- tests: 6 run tests with AIR equivalence (mutex counter, select draw,
select same value, shield, join_cancel forwarding, cancelled recv), 10
rejects (E4304 x3, E3001, E2101, E7005 x2, E7004, E3101 x2, E4101)
- spec 15 §7/§9, quick reference, bundle notes, plan
This commit is contained in:
1 parent
609b6bf86e
commit
154c39865f
24 files changed
+912
-50
No files matched your search
@@ -154,7 +154,7 @@ region.reset(r);
|
||||
|
||||
## 7. Concurrency
|
||||
|
||||
Tasks and channels work (layer 7). `select`, `lock`/`mutex`, `shield`, `task.check_cancel` and `task.join_cancel` are layer 8, not implemented yet: `aji check` reports them as not implemented (exit code 3).
|
||||
Tasks, channels, `select`, `lock`/mutex, `shield` and the cancellation operations all work.
|
||||
|
||||
```aji
|
||||
mut d = data; // data: [u64; 8]
|
||||
@@ -203,13 +203,13 @@ scope s { // every task spawned in s must
|
||||
|
||||
```aji
|
||||
select {
|
||||
recv(rx_a) { ok(x) => { … } closed => { … } }
|
||||
recv(rx_a) { ok(x, job) => { … } closed(job) => { … } }
|
||||
send(tx_b, move job) { ok => { … } closed(job) => { … } }
|
||||
cancelled(job) => { … }
|
||||
}
|
||||
```
|
||||
|
||||
Among ready arms, the scheduler's seeded choice decides. Arms where `job` was not sent bind it back.
|
||||
Among ready arms, the scheduler's seeded choice decides. Every edge where `job` was not sent binds it back, after the edge's own value: `ok(x, job)`.
|
||||
- **Mutex:**
|
||||
|
||||
```aji
|
||||
|
||||
Reference in new issue
Block a user