package async_unix

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Instead of calling Scheduler.go, the External module can be used to drive Async with an external loop, manually running regular Async cycles. This is useful to integrate Async with another event loop system.

val run_one_cycle : max_wait:[ `Zero | `Until of Time_ns_unix.t | `Indefinite ] -> (Core_unix.File_descr.t * Read_write_pair.Key.t) list

Run a single Async cycle. This function must be called:

  • from the same thread every time
  • nonrecursively
  • while holding the Async lock
  • regularly, to ensure Async callbacks get run

Whether this function may block is controlled by the max_wait parameter. Note that e.g. run_one_cycle ~max_wait:(`Until t) may return:

  • before t, if something occurs that wakes up Async, such as activity on a file descriptor, a timeout occurring, or reaching max_inter_cycle_timeout
  • after t, if there are Async jobs to run and some of them take a long time. That is, max_wait only controls the time spent blocking, not the time spent running jobs.

Returns a collection of readiness events on file descriptors registered via register_fd below

val run_cycles_until_determined : 'a Async_kernel.Deferred.t -> 'a

Calls run_one_cycle zero or more times until the given Deferred is determined

val current_thread_can_cycle : unit -> bool

Returns true if the current thread can use run_one_cycle. Returns false if the Async scheduler is running in another thread. Must not be called from within Async. Must be called while holding the Async lock.

val register_fd : Core_unix.File_descr.t -> bool Read_write_pair.t -> unit Core.Or_error.t

Register a file descriptor for which run_one_cycle will return readiness events. Async will not do any I/O or close this descriptor.

val unregister_fd : Core_unix.File_descr.t -> unit Core.Or_error.t

Remove a registration added by register_fd

val is_registered : Core_unix.File_descr.t -> bool

Check whether a file descriptor is currently registered via register_fd

OCaml

Innovation. Community. Security.