Source src/silo:std.effects.concurrent
1##! Concurrent effect — spawn, await, cancel, timeout. 2##! 3##! Sub-effect of `IO`. The broader concurrency model (Mutex / RwLock / 4##! Atomic / channels) lives in `silo:std.sync`. 5##! 6##! The current shape is a flat `+Concurrent` with `AnyUInt` task 7##! handles and `AnyInt` durations. The typed split into 8##! `+Executor` / `+Thread` / `+Concurrent` with a typed `(Handle val)` 9##! return arrives once associated effect types and region-scoped 10##! `local` records are wired. 11 12:use 13 :open core AnyInt AnyUInt Bool Unit 14 :open effects.io IO 15:end 16 17# si[impl effect.concurrent.decl+1] 18## Concurrent effect — async task spawn / await / cancel / timeout. 19## Task handles are carried as `AnyUInt` identifiers and durations as 20## `AnyInt` (interpreted by the host) in this placeholder decl. 21:effect(pub) Concurrent IO 22 # si[impl effect.executor.spawn] 23 ## Spawn a new task; returns a task handle identifier. 24 .spawn ( -> AnyUInt ) 25 # si[impl effect.concurrent.await] 26 ## Suspend until the task completes; consumes the handle. 27 .await ( AnyUInt -> ) 28 # si[impl effect.concurrent.cancel] 29 ## Request cancellation of the task; consumes the handle. 30 .cancel ( AnyUInt -> ) 31 # si[impl effect.concurrent.yield] 32 ## Cooperatively yield execution to the scheduler. 33 .yield-now ( -> ) 34 # si[impl effect.concurrent.timeout+1] 35 ## Wait up to `n` units for the task; `true` on completion, `false` on timeout. 36 .timeout ( AnyInt AnyUInt -> Bool ) 37:end