Module Async_kernel__.Mvar
val sexp_of_t : ('a -> Ppx_sexp_conv_lib.Sexp.t) -> ('phantom -> Ppx_sexp_conv_lib.Sexp.t) -> ('a, 'phantom) t -> Ppx_sexp_conv_lib.Sexp.t
module Read_write : sig ... endmodule Read_only : sig ... endval create : unit -> 'a Read_write.tval is_empty : (_, _) t -> boolval put : ('a, [> Core_kernel.write ]) t -> 'a -> unit Async_kernel.Deferred.tput t awaits untilis_empty t, and then doesset t a. If there are multiple concurrentputs, there is no fairness guarantee (i.e.,puts may happen out of order or may be starved).
val set : ('a, [> Core_kernel.write ]) t -> 'a -> unitset t asets the value inttoa, even ifnot (is_empty t). This is useful if you want takers to have last-value semantics.
val update : ('a, Core_kernel.read_write) t -> f:('a option -> 'a) -> unitupdate t ~fappliesfto the value intandsetstto the result. This is useful if you want takers to have accumulated-value semantics.
val update_exn : ('a, Core_kernel.read_write) t -> f:('a -> 'a) -> unitupdate_exnis likeupdate, except it raises ifis_empty t.
val read_only : ('a, [> Core_kernel.read ]) t -> ('a, Core_kernel.read) tval write_only : ('a, [> Core_kernel.write ]) t -> ('a, Core_kernel.write) tval value_available : (_, [> Core_kernel.read ]) t -> unit Async_kernel.Deferred.tvalue_available treturns a deferreddthat becomes determined when a value is int.ddoes not include the value intbecause that value may change afterdbecomes determined and before a deferred bind ondgets to run.Repeated calls to
value_available twill always return the same deferred until thetis filled.
val take : ('a, [> Core_kernel.read ]) t -> 'a Async_kernel.Deferred.ttake treturns a deferred that, whentis filled, becomes determined with the value oftand and clearst. If there are multiple concurrent calls totakethen only one of them will be fulfilled and the others will continue waiting on future values. There is no ordering guarantee for whichtakecall will be filled first.
val take_now : ('a, [> Core_kernel.read ]) t -> 'a optiontake_nowis an immediate form oftake.
val take_now_exn : ('a, [> Core_kernel.read ]) t -> 'aval taken : (_, [> Core_kernel.write ]) t -> unit Async_kernel.Deferred.ttaken treturns a deferred that is filled the next timetakeclearst.
val peek : ('a, [> Core_kernel.read ]) t -> 'a optionpeek treturns the value intwithout clearingt, or returnsNoneisis_empty t.
val peek_exn : ('a, [> Core_kernel.read ]) t -> 'apeek_exn tis likepeek, except it raises ifis_empty t.
val pipe_when_ready : ('a, [> Core_kernel.read ]) t -> 'a Async_kernel.Pipe.Reader.tpipe_when_ready treturns a pipe, then repeatedly takes a value fromtand writes it to the pipe. After each write,pipe_when_readywaits for the pipe to be ready to accept another value before taking the next value. Once the pipe is closed,pipe_when_readywill no longer take values fromt.Notice that this implementation effectively creates an extra buffer of size 1, so when you read from the pipe you can read a stale value (even though a fresh one should come immediately afterwards), and a value will be taken from the MVar even if it's never read from the pipe.
There is no protection against creating multiple pipes or otherwise multiple things trying to
takeconcurrently. If that happens, it's not specified which of the pipes will get the value.