Await.StackSourceA multi-producer, multi-consumer concurrent stack.
A simple, list-based multi-producer multi-consumer stack which provides both lock-free and blocking operations.
include sig ... endval sexp_of_t :
('a : value mod contended). ('a -> Sexplib0.Sexp.t) ->
'a t ->
Sexplib0.Sexp.tcreate () creates and returns a new empty stack.
The optional padded argument specifies whether to pad the data structure to avoid false sharing. See Atomic.make for a longer explanation.
push t a enqueues a at the head of t.
pop await t removes and returns the most-recently-pushed value from the head of t, blocking using await if t is empty.
val pop_or_cancel :
Await_kernel.Await.t @ local ->
Await_kernel.Cancellation.t @ local ->
'a t @ local ->
'a Await_kernel.Or_canceled.t @ portable contended @@ portablepop_or_cancel await c t is Completed (pop await t) if c is not cancelled, otherwise it is Canceled.
pop_nonblocking t removes and returns the most-recently-pushed value from the head of t, or returns Null if the stack is empty.
drain t removes and returns all items from t without blocking, returning a list with the most-recently-enqueued item first.
val drain_blocking :
Await_kernel.Await.t @ local ->
'a t @ local ->
'a Base.list @ portable contended @@ portabledrain_blocking await t removes and returns all items from t, blocking using await if t is empty. Returns a list with the most-recently-enqueued item first.
val drain_blocking_or_cancel :
Await_kernel.Await.t @ local ->
Await_kernel.Cancellation.t @ local ->
'a t @ local ->
'a Base.list Await_kernel.Or_canceled.t @ portable contended @@ portabledrain_blocking_or_cancel await c t is Completed (drain_blocking await t) if c is not cancelled, otherwise it is Canceled.