Await.ScopeSourceA scope for structured concurrency.
type !'a
t : (value mod contended non_float portable unforkable unyielding) with 'a @@ contended portablet represents a scope for structured concurrency.
Scopes are usually created via with_ with a local context value which is provided to each task, may have new tasks added to them (from any implementation of concurrency), and wait until all tasks exit. This way it is safe to destroy resources used within the scope after the scope exits.
Any uncaught exception within the scope will terminate the scope and all the tasks spawned into it and close the scope. This way error handling becomes simpler as one doesn't have to otherwise explicitly arrange for termination of siblings and children in case of unhandled errors.
val with_ :
Await_kernel.Await.t @ local ->
'a @ portable ->
f:
(Await_kernel.Await.t @ local ->
('a t @ local ->
'b @ unique once) @ local once) @ local once unyielding ->
'b @ unique once @@ portablewith_ await context ~f calls f scope with a new scope for concurrency and does not return until all the tasks added to the scope have exited. An uncaught exception from f or any task added to the scope will terminate all of the tasks and the exception will then be raised out of with_ after all of the tasks have exited.
Allows creating non-local scopes for performing unstructured concurrency.
context scope returns the context value that the scope was created with.
terminator scope returns the terminator of the scope.
failure returns This (exn, bt) containing the first uncaught exception raised within the scope or Null in case there have been none. This is usually only called after the scope is known to have finished.