Files
aji/tests/conformance/phase3/run/cancel_join_forward.air
T
dev aaf32b6853 Phase 3: channels, mutex, select and cancellation points (RFC 0012)
- features cancellation, channels, sync supported
- AIR model/parser/printer: shield, sender<T>, receiver<T>, mutex<T>,
  guard<T>; task.check_cancel, task.join.cancel, task.shield.*,
  channel.*, select (bracketed arms), mutex.*
- verifier: arities (E5002), element rules (E4001/E1001, E0006
  channel_transfer), guard_transfer gating, task.wait effect (gated for
  task.join by cancellation), per-edge consumption with values and
  handles returned as block parameters, loans moved to the handle on
  task.join.cancel's cancelled edge, shield order (E4305), guard
  children (E2102), critical-section rule (E4304)
- interpreter: waiting-operation rule (ready, else cancelled if
  observable, else wait), shield depth, bounded and rendezvous channels
  with FIFO offers, drain-then-close receiver, budget release at the
  last close, select with seeded draw among ready arms, mutex wakeups;
  schedule record also after a select draw
- report counts task.spawn, task.wait and channel allocations
- spec erratum: mutex<T> is linear (format 0 has no droppable
  move-only class)
- 30 new conformance tests (10 run with schedules, 4 accept, 16
  reject); 6000-run schedule stress and 4350 mutants without failure
2026-10-04 16:49:37 +03:00

49 lines
1.1 KiB
LLVM

; task.join.cancel: a cancelled parent gets its child's handle back (not joined,
; loans kept), forwards the request and joins normally.
; expect: run
; schedules: 20
; result: 13
; phase: 3
; spec: docs/spec/04-concurrency-and-atomics.md
module test.cancel_join_forward
air 0
lang 0.1
features [cancellation, effects, ownership, tasks]
fn @main() -> u64
effects [task.spawn, task.wait]
entry:
%sc = task.scope.begin
%p = task.spawn %sc, @parent()
task.cancel %p
%r = task.join %p
task.scope.end %sc
ret %r
fn @parent() -> u64
effects [task.spawn, task.wait]
entry:
%sc = task.scope.begin
%c = task.spawn %sc, @child()
task.join.cancel %c, ok -> @joined, cancelled -> @cancelled
joined(%v: u64):
task.scope.end %sc
ret %v
cancelled(%c2: task<u64>):
task.cancel %c2
%v2 = task.join %c2
task.scope.end %sc
%ten = const.u64 10
%r = add.checked.u64 %v2, %ten
ret %r
fn @child() -> u64
effects []
entry:
br @spin()
spin:
task.check_cancel, ok -> @spin, cancelled -> @stop
stop:
%three = const.u64 3
ret %three