Page
Library
Module
Module type
Parameter
Class
Class type
Source
Picos_aux_mpscqSourceLock-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.
A multi-producer, single-consumer queue.
create () returns a new empty multi-producer, single-consumer queue.
ℹ️ 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.
⚠️ 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.
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]