crow/parallel.crow (source)
await[t] t(a t future)
await-result[t] (t, exception-and-backtrace) result(a t future)
yield-fiber void()
Just yields the fiber temporarily. It may be restarted immediately.
new[t] t future(value t)
Converts a value to a future resolved with that value.
rejected[t] t future(err exception-and-backtrace)
Future resolved with an exception.
parallel record nominal
with-block[t] t future(anonymous parallel, f shared t(void))
Run f in a new fiber with a new exclusion and return a future for its result.
new-exclusion record nominal
This is like running something with parallel and then waiting on it.
The purpose is to allow other fibers with the current exclusion to run while waiting.
with-block[t] t(anonymous new-exclusion, f shared t(void))
later record nominal
with-block[t] t future(anonymous later, f mut t(void)) t shared
sharedRun f in a new fiber with the current exclusion. So it can't run until the current fiber yields.
forget[t] void(a t future)
Does not await the future, but will log any exceptions from the future once it is done.
fire-and-forget record nominal
with-block void(anonymous fire-and-forget, f shared void(void))
Runs 'f' in parallel and logs any exceptions, but does not await it.
parallel-collection[col] record
collectioncol
parallel[col] col parallel-collection(a col)
for-loop[out-elem, in-col, in-elem] out-elem array(a in-col parallel-collection, f shared out-elem(in-elem)) out-elem shared, in-elem shared, (in-col, in-elem) iterate, in-col size
sharedsharediteratesizeFor each element of a, runs f in parallel. Then awaits them all.
for-loop[in-col, in-elem] void(a in-col parallel-collection, f shared void(in-elem)) (in-col, in-elem) iterate, in-col size, in-elem shared
iteratesizesharedSame as the above but returning 'void'.
parallel-concat[col] record nominal
collectioncol
Runs f in parallel for each element of a and concatenates results.
for-loop[out-elem, in-col, in-elem] out-elem array(a in-col parallel-concat, f shared out-elem array(in-elem)) out-elem shared, in-elem shared, (in-col, in-elem) iterate, in-col size
sharedsharediteratesizefilter[out-col, in-col, elem, builder] out-col(a in-col parallel-collection, f shared bool(elem)) (in-col, elem) iterate, in-col size, (out-col, elem, builder) build, elem shared
iteratesizebuildsharedRuns f in parallel for each element of a and returns results for which it was true.
chunked-parallel[col] record nominal
collectioncolchunk-sizenat64
Works like parallel, but works in groups of 'chunk-size' elements to reduce parallelism.
chunkable[col, iter, elem] spec col shared, elem shared, (col, iter) groupable, (col, elem) iterate
sharedsharedgroupableiteratefor-loop[out-elem, in-col, in-iter, in-elem] out-elem array(a in-col chunked-parallel, f shared out-elem(in-elem)) out-elem shared, (in-col, in-iter, in-elem) chunkable
sharedchunkablefor-loop[in-col, in-iter, in-elem] void(a in-col chunked-parallel, f shared void(in-elem)) (in-col, in-iter, in-elem) chunkable
chunkablefilter[out-col, in-col, in-iter, elem, builder] out-col(a in-col chunked-parallel, f shared bool(elem)) out-col shared, (in-col, in-iter, elem) chunkable, (out-col, elem, builder) build
sharedchunkablebuildfuture[t] builtin
In a JS build, this is a 'Promise'.