Await_sync.MvarA linear mutable cell that can be either empty or full (i.e., hold a single unique value at a time).
val create : ?padded:bool @ local -> (unit -> 'a t) @ local @@ portablecreate () returns a new empty mvar.
The optional padded argument specifies whether to pad the data structure to avoid false sharing. See Atomic.make for a longer explanation.
val create_full :
?padded:bool @ local ->
('a @ unique once portable contended ->
'a t) @ local @@ portablecreate_full v returns a new mvar filled with v.
val put :
Await_kernel.Await.t @ local ->
('a t @ local ->
('a @ unique once portable contended ->
unit) @ local) @ local @@ portableput w t a waits using w until the mvar t is empty, and then sets the value to a. If there are multiple concurrent puts, there is no fairness guarantee (ie, puts may happen out of order or may be starved).
val put_or_cancel :
Await_kernel.Await.t @ local ->
(Await_kernel.Cancellation.t @ local ->
('a t @ local ->
('a @ unique once portable contended ->
unit Await_kernel.Or_canceled.t) @ local) @ local) @ local @@ portableput_or_cancel w c t a is Completed (put w t a) if c is not canceled, otherwise it is Canceled.
module Ok_or_already_full : sig ... endval try_put :
'a t @ local ->
('a @ unique once portable contended ->
Ok_or_already_full.t) @ local @@ portabletry_put t a sets the value of t to a and returns Ok if it is empty, otherwise it returns Already_full.
val put_exn :
'a t @ local ->
('a @ unique once portable contended ->
unit) @ local @@ portableput_exn t a sets the value of t to a.
val take :
Await_kernel.Await.t @ local ->
('a t @ local ->
'a @ unique once portable contended) @ local @@ portabletake w t waits using w until the mvar t is full, then clears it and returns its value. If there are multiple concurrent calls to take then only one will be fulfilled and the others will continue waiting on future values. There is no ordering guarantee for which take call will be filled first.
val take_or_cancel :
Await_kernel.Await.t @ local ->
(Await_kernel.Cancellation.t @ local ->
('a t @ local ->
'a Await_kernel.Or_canceled.t @ unique once portable contended) @ local) @ local @@ portabletake_or_cancel w c t a is Completed (take w t a) if c is not canceled, otherwise it is Canceled.
val try_take :
'a t @ local ->
'a or_null @ unique once portable contended @@ portabletry_take t empties the mvar t and returns This v if it is currently full, or returns Null otherwise.
val take_exn : 'a t @ local -> 'a @ unique once portable contended @@ portabletake_exn empties the mvar t and returns its value v if it is currently full.
val is_full : _ t @ local -> bool @@ portableis_full t is true if the mvar t is currently full.
val wait_until_empty :
Await_kernel.Await.t @ local ->
(_ t @ local ->
unit) @ local @@ portablewait_until_empty w t waits until the mvar t becomes empty.
val wait_until_empty_or_cancel :
Await_kernel.Await.t @ local ->
(Await_kernel.Cancellation.t @ local ->
(_ t @ local ->
unit Await_kernel.Or_canceled.t) @ local) @ local @@ portablewait_until_empty_or_cancel w c t is Completed (wait_until_empty w t) if c is not canceled, otherwise it is Canceled.