Module Action.Unblocker

Action invocation unblockers.

Action invocation unblockers are provided by libraries defining actions whose invocations rely on external factors to synchronize. See for example Affect_unix.Unix.unblocker.

Note. For the time being, due to the blocking behaviour of Unblocker.Domain_local.unblock when invoked with block:true, unblockers are not naturally composable. The best that libraries can do is to cooperate to try to give users a handle on the constituents of the unblocking mecanisms so that composite unblockers can be easily devised (see for example the components that make up the Affect_unix.Unix.unblocker, though those are still a bit untidy and not exposed for the time being).

Domain local unblocker

module Domain_local : sig ... end

Domain local unblockers.

Unblockers

type index = int

The type for domain scheduler indexes. Index 0 is the only index that is guaranteed to exist, it corresponds to the scheduler's main domain.

Note. These indices are allocated by the scheduler, they are a separate concept from Domain.self_index indices.

type init = domain_count:int -> unit

The type for initializing an unblocker. See init.

type domain_local = index -> Domain_local.t

The type for getting a domain local unblocker for a given domain index. See domain_local.

type domain_install = Domain_local.t -> unit

The type for installing a local unblocker on a domain. See domain_install.

type domain_uninstall = Domain_local.t -> unit

The type for uninstalling a local unblocker on a domain. See domain_uninstall.

type deinit = unit -> unit

The type for deinitializating an unblocker. See deinit.

type t = unblocker

The type for unblockers.

val make : init:init -> domain_local:domain_local -> domain_install:domain_install -> domain_uninstall:domain_uninstall -> deinit:deinit -> unit -> t

make is an unblocker with given properties. See accessors for details on how these functions end up being called by the scheduler.

val init : t -> domain_count:int -> unit

init u ~domain_count is called once by the scheduler main domain with the total number of domains that are going to exist in the scheduler (they may or may not have been already spawned). This call occurs before any call to domain_local, domain_install, domain_uninstall or deinit.

val domain_local : t -> index -> Domain_local.t

domain_local u i is called once by the scheduler for each domain i in the scheduler to get the local unblocker for domain i. This call is made after init has been called. The domain that executes the function local u i is unspecified.

val domain_install : t -> Domain_local.t -> unit

domain_install u l is called once by the domain i of the scheduler with the result of local u i.

val domain_uninstall : t -> Domain_local.t -> unit

domain_uninstall u l is called once by the domain i of the scheduler after domain_install u l has been called just before the local scheduler of the domain finally stops. It is only called if a corresponding domain_install has been made.

val deinit : t -> unit -> unit

deinit u () is called once by the scheduler main domain, after all the scheduler domains have been joined. It's only called if init was ever called on u.

Unblock nothing

val nothing : unit -> t

nothing is an unblocker that unblocks nothing. It is the default of Fun.Async.main.