Imandrakit_sync.Switch
Switch to cancel tasks.
A switch can be flipped to false once, and remains off forever afterwards.
val pp :
Ppx_deriving_runtime.Format.formatter ->
t ->
Ppx_deriving_runtime.unit
val show : t -> Ppx_deriving_runtime.string
val with_on_turn_off : t -> (unit -> unit) -> (unit -> 'a) -> 'a
with_on_turn_off sw cb f
calls f()
. Within the context where f()
is running, sw
turning off will trigger cb()
. Once f()
has terminated, cb
is disabled and will not be called.
val on_turn_off : t -> (unit -> unit) -> unit
on_turn_off sw f
will call f()
when sw
is turned off. If sw
is already off then f()
is called immediately. NOTE f
really should not fail.
val is_on : t -> bool
val is_off : t -> bool
val turn_off : ?trace:bool -> t -> unit
val turn_off' : ?trace:bool -> t -> [ `Was_off | `Was_on ]
Turn off switch, return previous state