Module Async_kernel.Bvar
A Bvar
is a synchronization point that allows one to broadcast
a value to clients wait
ing on the broadcast. With a Bvar
, one can efficiently notify multiple clients of edge-triggered conditions, repeating as each edge trigger occurs.
Bvar
is like an ivar/deferred, except that it is always "empty" and can be repeatedly "filled" (via broadcast
).
Another way to view Bvar
is as a restriction of Condition
that supports only broadcast, not signal
ing a single waiter. Dropping signal
simplifies the implementation significantly.
The 'permissions
parameter is used for read/write permissions. Also see Perms
.
type ('a, -'permissions) t
= ('a, 'permissions) Async_kernel__.Types.Bvar.t
val sexp_of_t : ('a -> Ppx_sexp_conv_lib.Sexp.t) -> ('permissions -> Ppx_sexp_conv_lib.Sexp.t) -> ('a, 'permissions) t -> Ppx_sexp_conv_lib.Sexp.t
include Core_kernel.Invariant.S2 with type ('a, 'permissions) t := ('a, 'permissions) t
val invariant : 'a Base__.Invariant_intf.inv -> 'b Base__.Invariant_intf.inv -> ('a, 'b) t Base__.Invariant_intf.inv
val create : unit -> ('a, Core_kernel.read_write) t
val wait : ('a, [> Core_kernel.read ]) t -> 'a Async_kernel__.Deferred0.t
wait t
becomes determined by the next call tobroadcast t a
.
val broadcast : ('a, [> Core_kernel.write ]) t -> 'a -> unit
val has_any_waiters : ('a, _) t -> bool
has_any_waiters t
returnstrue
iff there has been a call towait t
since the most recent call tobroadcast t
.