Saturn.Bounded_queueLock-free bounded Queue.
This module implements a lock-free bounded queue based on Michael-Scott's queue algorithm. Adding a capacity to this algorithm adds a general overhead to the operations, and thus, it is recommended to use the unbounded queue Saturn.Queue if you don't need it.
val create : ?capacity:int -> unit -> 'a tcreate ~capacity () creates a new empty bounded queue with a maximum capacity of capacity. The default capacity value is Int.max_int.
val of_list_exn : ?capacity:int -> 'a list -> 'a tof_list_exn ~capacity list creates a new queue from a list.
val length : 'a t -> intlength queue returns the number of elements currently in the queue.
val capacity_of : 'a t -> intcapacity_of queue returns the maximum number of elements that the queue can hold.
val is_empty : 'a t -> boolis_empty queue returns true if the queue is empty, otherwise false.
val is_full : 'a t -> boolis_full queue returns true if the queue is full, otherwise false.
val peek_exn : 'a t -> 'apeek_exn queue returns the first element of the queue without removing it.
val peek_opt : 'a t -> 'a optionpeek_opt queue returns Some of the first element of the queue without removing it, or None if the queue is empty.
val pop_exn : 'a t -> 'apop_exn queue removes and returns the first element of the queue.
val pop_opt : 'a t -> 'a optionpop_opt queue removes and returns Some of the first element of the queue, or None if the queue is empty.
val drop_exn : 'a t -> unitdrop_exn queue removes the top element of the queue.
Raised when push_exn is applied to a full queue.
val push_exn : 'a t -> 'a -> unitpush_exn queue element adds element at the end of the queue.
val try_push : 'a t -> 'a -> booltry_push queue element tries to add element at the end of the queue. Returns true if the element was successfully added, or false if the queue is full.