package eio

  1. Overview
  2. Docs

Suspend a fiber and enter the scheduler.

val enter : (Fiber_context.t -> 'a Effects.enqueue -> unit) -> 'a

enter fn suspends the calling fiber and calls fn ctx enqueue in the scheduler's context. This should arrange for enqueue to be called when the fiber should be resumed. enqueue is thread-safe and so can be called from another domain or systhread.

ctx should be used to set a cancellation function. Otherwise, the operation is non-interruptable. If the caller's cancellation context is already cancelled, enter immediately aborts.

val enter_unchecked : (Fiber_context.t -> 'a Effects.enqueue -> unit) -> 'a

enter_unchecked is like enter except that it does not perform the initial check that the fiber isn't cancelled (this is useful if you want to do the check yourself, e.g. because you need to unlock a mutex if cancelled).