Kcas_data.QueueFirst-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.
val create : unit -> 'a tcreate () returns a new empty queue.
module Xt : sig ... endExplicit transaction log passing on queues.
val is_empty : 'a t -> boolis_empty s determines whether the queue q is empty.
val length : 'a t -> intlength q returns the length of the queue q.
val clear : 'a t -> unitclear q removes all elements from the queue q.
val to_seq : 'a t -> 'a Stdlib.Seq.tto_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.
val add : 'a -> 'a t -> unitadd x q adds the element x at the end of the queue q.
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.
val peek_blocking : ?timeoutf:float -> 'a t -> 'apeek_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.
val take_blocking : ?timeoutf:float -> 'a t -> 'atake_blocking q removes and returns the first element in queue q, or blocks waiting for the queue to become non-empty.
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.
val take_all : 'a t -> 'a Stdlib.Seq.ttake_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.
val peek : 'a t -> 'apeek q returns the first element in queue s, or raises Empty if the queue is empty.
val take : 'a t -> 'atake s removes and returns the first element in queue q, or raises Empty if the queue is empty.
val iter : ('a -> unit) -> 'a t -> unititer f s is equivalent to Seq.iter f (to_seq s).
val fold : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'bfold f s is equivalent to Seq.fold_left f a (to_seq s).