conc/scope
lib/conc/scope.vklib/conc/scope.vk
Structured task-group concurrency helpers over Veko's shared-nothing spawn and task/await.
Ensures every spawned task in a Scope is awaited before scope completion so zero orphan tasks leak,
propagating the first worker err (combine with /or).
new = fn [] Scope
Creates a new empty structured concurrency Scope.
Executable Example
use [sc = conc/scope]
mut grp = sc/new
sc/add mut grp (spawn [ 10 + 11 ])
sc/add mut grp (spawn [ 20 + 1 ])
res = sc/await-all mut grp
if (len res) != 2 or res[0] != 21 or res[1] != 21 [ err 'scope await-all' ] else [ .ok ]
await-all = fn [mut s Scope] block
Awaits all tasks in s in registration order, draining every handle even if an earlier task errored,
and returns the ordered block of results (or the first err encountered).
await-settled = fn [mut s Scope] map
Awaits all tasks in s and returns { ok = block, errors = block } without short-circuiting.