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
@@ -9,21 +9,21 @@ module demo.qrselect
|
||||
fn main(heap: cap<mem.alloc>) -> u64
|
||||
effects [mem.alloc, task.wait]
|
||||
{
|
||||
let job = 9u64;
|
||||
var which: u64 = 0;
|
||||
match channel.make<u64>(1, heap) {
|
||||
ok(tx_a, rx_a) => {
|
||||
match channel.make<u64>(1, heap) {
|
||||
match channel.make<own<u64>>(1, heap) {
|
||||
ok(tx_b, rx_b) => {
|
||||
let job = own.new(9u64, heap) or trap;
|
||||
channel.close_sender(move tx_a);
|
||||
select {
|
||||
recv(rx_a) { ok(x) => { which = 2; } closed => { which = 1; } }
|
||||
send(tx_b, move job) { ok => { which = 1; } closed(job) => { which = 3; } }
|
||||
cancelled(job) => { trap; }
|
||||
recv(rx_a) { ok(x, job) => { own.free(move job); which = 2; } closed(job) => { own.free(move job); which = 1; } }
|
||||
send(tx_b, move job) { ok => { which = 1; } closed(job) => { own.free(move job); which = 3; } }
|
||||
cancelled(job) => { own.free(move job); trap; }
|
||||
}
|
||||
channel.close_sender(move tx_b);
|
||||
match channel.close_receiver(move rx_a) { ok => {} pending(rx_a) => { trap; } }
|
||||
match channel.recv(rx_b) { ok(v) => {} closed => {} cancelled => { trap; } }
|
||||
match channel.recv(rx_b) { ok(v) => { own.free(move v); } closed => {} cancelled => { trap; } }
|
||||
match channel.close_receiver(move rx_b) { ok => {} pending(rx_b) => { trap; } }
|
||||
}
|
||||
err(e) => { trap; }
|
||||
|
||||
Reference in new issue
Block a user