Module Kcas_data.Queue Source First-In First-Out (FIFO) queue.
The interface provides a subset of the OCaml Stdlib.Queue module. transfer and add_seq are not provided at all. Compositional versions of iter , fold , peek , top , and take are not provided.
The queue implementation is designed to avoid contention between a producer and a consumer operating concurrently. The implementation is also designed to avoid starvation. Performance in most concurrent use cases should be superior to what can be achieved with one or two locks.
Common interfaceThe type of queues containing elements of type 'a.
Raised when take or peek is applied to an empty queue.
create () returns a new empty queue.
copy q returns a copy of the queue q.
Compositional interfaceExplicit transaction log passing on queues.
Non-compositional interfaceis_empty s determines whether the queue q is empty.
length q returns the length of the queue q.
clear q removes all elements from the queue q.
swap q1 q2 exchanges the contents of the queues q1 and q2.
to_seq s returns a concurrency and parallelism safe sequence for iterating through the elements of the queue front to back.
The sequence is based on a constant time, O(1), snapshot of the queue and modifications of the queue have no effect on the sequence.
add x q adds the element x at the end of the queue q.
Source val push : 'a -> 'a t -> unitpush is a synonym for add .
Source val peek_opt : 'a t -> 'a optionpeek_opt q returns the first element in queue q, without removing it from the queue, or returns None if the queue is empty.
Source val peek_blocking : ?timeoutf :float -> 'a t -> 'a peek_blocking q returns the first element in queue q, without removing it from the queue, or blocks waiting for the queue to become non-empty.
Source val take_blocking : ?timeoutf :float -> 'a t -> 'a take_blocking q removes and returns the first element in queue q, or blocks waiting for the queue to become non-empty.
Source val take_opt : 'a t -> 'a optiontake_opt q removes and returns the first element in queue q, or returns None if the queue is empty.
take_all q removes and returns a concurrency and parallelism safe sequence for iterating through all the elements that were in the queue front to back.
peek q returns the first element in queue s, or raises Empty if the queue is empty.
top is a synonym for peek .
take s removes and returns the first element in queue q, or raises Empty if the queue is empty.
Source val iter : ('a -> unit) -> 'a t -> unititer f s is equivalent to Seq.iter f (to_seq s).
Source val fold : ('b -> 'a -> 'b ) -> 'b -> 'a t -> 'b fold f s is equivalent to Seq.fold_left f a (to_seq s).