package saturn_lockfree
Module Saturn_lockfree.Single_prod_single_cons_queueSource
Single producer single consumer queue.
Type of single-producer single-consumer non-resizable domain-safe queue that works in FIFO order.
create ~size_exponent:int returns a new queue of maximum size 2^size_exponent and initially empty.
size returns the size of the queue. This method linearizes only when called from either consumer or producer domain. Otherwise, it is safe to call but provides only an *indication* of the size of the structure.
Producer functions
Raised when push_exn is applied to a full queue.
This exception is meant to avoid allocations required by an option type. As such, it does not register backtrace information and it is recommended to use the following pattern to catch it.
match push_exn q v with
| () -> (* ... *)
| exception Full -> (* ... *)push q v adds the element v at the end of the queue q. This method can be used by at most one domain at a time.
try_push q v tries to add the element v at the end of the queue q. It fails it the queue q is full. This method can be used by at most one domain at a time.
Consumer functions
Raised when pop_exn or peek_exn is applied to an empty queue.
This exception is meant to avoid allocations required by an option type. As such, it does not register backtrace information and it is recommended to use the following pattern to catch it.
match pop_exn q with
| value -> (* ... *)
| exception Empty -> (* ... *)pop_exn q removes and returns the first element in queue q. This method can be used by at most one domain at a time.
pop_opt q removes and returns the first element in queue q, or returns None if the queue is empty. This method can be used by at most one domain at a time.
peek_exn q returns the first element in queue q. This method can be used by at most one domain at a time.