eio/lib_eunix/zzz.mli
Thomas Leonard 3713d9470b Split cancellation out from Switch
Cancellation and grouping are easier to handle separately.

`Fibre.both` no longer takes a switch, but instead just creates a new
cancellation context.
2021-11-11 19:13:49 +00:00

21 lines
741 B
OCaml

module Key : sig
type t
end
type t
(** A queue of scheduled events. *)
val create : unit -> t
(** [create ()] is a fresh empty queue. *)
val add : cancel_hook:Eio.Hook.t ref -> t -> float -> unit Suspended.t -> Key.t
(** [add ~cancel_hook t time thread] adds a new event, due at [time], and returns its ID.
[cancel_hook] will be released when the event is later returned by {!pop}. *)
val remove : t -> Key.t -> unit
(** [remove t key] removes an event previously added with [add]. *)
val pop : t -> now:float -> [`Due of unit Suspended.t | `Wait_until of float | `Nothing]
(** [pop ~now t] removes and returns the earliest thread due by [now].
If no thread is due yet, it returns the time the earliest thread becomes due. *)