#import "std/async"
Async module provides high-level interface for thread manipulation. In general, it's suitable for longer running parallel tasks expecting some input context and results returned back to the caller.
Warning: This module is in experimental state, new features or API changes may come in the future.
Async :: fn (TWorkerContext: type, TResult: type) type
Asynchronous task context holder holding internally created thread instance, input and output data of the worker function. Instance of this type is supposed to be initialized exclusively in async function call and its content is internal.
File: async.bl
Async2 :: fn (TWorkerContext: type, TResult: type) type
File: async.bl
async :: fn (ctx: *?TAsync, worker_context: , worker: *fn (ctx: ) )
Setup the async ctx
context structure and starts internally a new thread executing the worker
function. The
worker runtime context must be specified as worker_context
. The execution (worker return) result value is not
returned immediately since call to this function is not blocking. Use async_wait to get the cached
result value back.
File: async.bl
async2 :: fn (ctx: *?TAsync, worker_context: , worker: *fn (ctx: *) )
File: async.bl
async_wait :: fn (ctx: *?TAsync) #inline
Wait for the async job, executed by async call, to finish. This function blocks until the underlying job's thread exits. The result value is returned on success.
File: async.bl