Module Parallel_kernel.For_scheduler

module Result : sig ... end
val root_exn : Base.unit Thunk.t @ once portable -> (promote:((Base.unit -> Base.unit) @ once portable -> Base.unit) @ portable -> (wake:(n:Base.int -> Base.unit) @ portable -> (lazy_:Base.bool -> (Base.unit -> Base.unit) @ once portable) @ once) @ once) @ once

root_exn f ~promote ~wake creates a top-level, schedulable task representing the full execution of f. The functions f, promote, and wake must not raise exceptions. All schedulers must use root_exn to create the initial portable function they inject into the worker pool.

The functions promote and wake define the behavior of the scheduler. When the heartbeat mechanism determines enough work has occurred to amortize promotion overhead, it calls promote, which gives the scheduler an opportunity to distribute tasks to other domains. After promoting n tasks, wake ~n is called, which tells the scheduler how many workers it may want to wake up. If a heartbeat occurs during promote or wake, they may be re-entered.

  • raises Out_of_fibers

    if unable to allocate a fiber.

val await : t @ local -> (Await.Trigger.t -> Base.unit) @ local

await t trigger suspends the current task until trigger is signaled, at which point it will be re-promoted.

val with_heartbeat : (Base.unit -> Base.unit) @ local once -> Base.unit

with_heartbeat f assures the heartbeat thread is running for the duration of f.

val without_heartbeat : 'a. (Base.unit -> 'a) @ local once -> 'a

without_heartbeat f masks heartbeats for the duration of f.