Module Imandra_util.Switch

Switch to cancel tasks

A switch can be activated once, and remains activated forever afterwards

type t
val create : unit -> t
val activate : t -> unit
type cb_handle
val set_cb : t -> (unit -> unit) -> cb_handle

Set the callback that is called if activate is called

val remove_cb : cb_handle -> unit
val empty_cb_handle : cb_handle
val set_poll_cb : t -> (unit -> unit) -> unit

Set a callback to call to perform some (quick) background polling

val with_cb : t -> (unit -> unit) -> (unit -> 'a) -> 'a

Adds callback, computes the function, then remove the callback

val set_cb_opt : t option -> (unit -> unit) -> cb_handle
val with_cb_opt : t option -> (unit -> unit) -> (unit -> 'a) -> 'a
val activated : t -> bool

is the switch already activated?

val poll : t -> unit

Do a bit of background work (e.g. polling)