Module Domain

module Domain: sig .. end

type 'a t 

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 re-raised by join d.

type id = private int 

Domains have unique integer identifiers

val get_id : 'a t -> id

get_id d returns the identifier of the domain d

val self : unit -> id

self () is the identifier of the currently running domain

val at_first_spawn : (unit -> unit) -> unit

Register the given function to be called before any domain is spawned (except the initial domain) and before any function registered with Domain.at_startup is called. The functions registered with at_first_spawn are called in 'last in, first out' order: the function most recently added with at_first_spawn is called first.

val at_exit : (unit -> unit) -> unit

Register the given function to be called at when a spawned domain exits. This function is also registered with at_exit. If the registered function raises an exception, the exceptions are ignored. The registered functions are called in 'last in, first out' order: the function most recently added with at_exit is called first.

val at_startup : (unit -> unit) -> unit

Register the given function to be called when a domain starts. This function is called before the callback specified to spawn f is executed. The registered functions are called in 'last in, first out' order: the function most recently added with at_startup is called first.

val cpu_relax : unit -> unit

If busy-waiting, calling cpu_relax () between iterations will improve performance on some CPU architectures

val set_name : string -> unit

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.

val is_main_domain : unit -> bool

is_main_domain () returns true if called from the initial domain.

module DLS: sig .. end