Stdlib.Domain
A domain of type 'a t
runs independently, eventually producing a result of type 'a, or an exception
val spawn : (unit -> 'a) -> 'a t
spawn f
creates a new domain that runs in parallel with the current domain.
val join : 'a t -> 'a
join d
blocks until domain d
runs to completion. If d
results in a value, then that is returned by join d
. If d
raises an uncaught exception, then that is thrown by join d
. Domains may only be joined once: subsequent uses of join d
raise Invalid_argument.
val self : unit -> id
self ()
is the identifier of the currently running domain
Register the given function to be called before the first domain is spawned.
Register the given function to be called at when a domain exits. This function is also registered with Stdlib.at_exit
. If the registered function raises an exception, the exceptions are ignored.
Register the given function to be called when a domain starts. This function is called before the callback specified to spawn f
is executed.
If busy-waiting, calling cpu_relax () between iterations will improve performance on some CPU architectures
set_name s
set the domain's thread name to s
. s
should not be longer than 15 characters. If s
is longer than 15 characters, raise Invalid_argument.
module DLS : sig ... end
Domain-local Storage