package picos_aux
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=862d61383e2df93a876bedcffb1fd1ddc0f96c50b0e9c07943a2aee1f0e182be
sha512=87805379017ef4a7f2c11b954625a3757a0f1431bb9ba59132202de278b3e41adbe0cdc20e3ab23b7c9a8c5a15faeb7ec79348e7d80f2b14274b00df0893b8c0
doc/picos_aux.mpscq/Picos_aux_mpscq/index.html
Module Picos_aux_mpscq
Source
Lock-free multi-producer, single-consumer queue.
🏎️ This data structure is optimized for use as the ready queue of a fair (i.e. FIFO) single-threaded scheduler.
API
A multi-producer, single-consumer queue.
create ()
returns a new empty multi-producer, single-consumer queue.
Interface for producers
ℹ️ The operations in this section can be called by both any number of producers and the single owner / consumer of the queue.
push_head queue value
adds the value
to the head of the queue
.
Interface for the owner / consumer
⚠️ The operations in this section should only be called by the single owner / consumer of the queue.
pop_exn queue
tries to remove the value at the head of the queue
. Returns the removed value or raises Empty
in case the queue was empty.
pop_all queue
removes all values from the queue
and returns them as a sequence.
Examples
An example top-level session:
# let q : int Picos_aux_mpscq.t =
Picos_aux_mpscq.create ()
val q : int Picos_aux_mpscq.t = <abstr>
# Picos_aux_mpscq.push q 42
- : unit = ()
# Picos_aux_mpscq.push_head q 76
- : unit = ()
# Picos_aux_mpscq.push q 101
- : unit = ()
# Picos_aux_mpscq.pop_exn q
- : int = 76
# Picos_aux_mpscq.pop_all q |> List.of_seq
- : int list = [42; 101]