Await_sync.ScopeA scope for structured concurrency.
t 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:('a t @ local -> 'b) @ local once ->
'b) @ local) @ local @@ 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.
module Global : sig ... endAllows creating non-local scopes for performing unstructured concurrency.
val context : 'a t @ local -> 'a @ local portable contended @@ portablecontext scope returns the context value that the scope was created with.
val terminator : 'a t @ local -> Await_kernel.Terminator.t @ local @@ portableterminator scope returns the terminator of the scope.
module Task_handle : sig ... endmodule Token : sig ... endval failure :
'a t @ local ->
(Base.exn * Base.Backtrace.t) Base.or_null @@ portablefailure 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.