package core
- Overview
- No Docs
You can search for identifiers within the package.
in-package search v0.2.0
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=7996e4063d51bdb7337ded720d31d4bc4c02cca467fad6b550c0f9ae8deae0bb
md5=85f006b0666f4fe05c566be8fda64cb2
doc/core.squeue/Squeue/index.html
Module Squeue
Thread-safe queue module, using locks.
val sexp_of_t :
('a -> Ppx_sexp_conv_lib.Sexp.t) ->
'a t ->
Ppx_sexp_conv_lib.Sexp.tval create : int -> 'a tcreate maxsize returns a synchronized queue bounded to have no more than maxsize elements.
val push : 'a t -> 'a -> unitBlocks until there's room on the queue, then pushes.
val push_uncond : 'a t -> 'a -> unitDoes not block, may grow the queue past maxsize.
val push_or_drop : 'a t -> 'a -> boolPushes an event on the queue if the queue is less than maxsize, otherwise drops it. Returns true if the push was successful
val length : 'a t -> intReturns the number of elements in the queue.
val pop : 'a t -> 'aPops an element off the queue, blocking until something is available
val lpop : 'a t -> 'a * intReturns the element popped and the length of the queue this element was popped.
val transfer_queue_in : 'a t -> 'a Core_kernel.Linked_queue.t -> unitTransfers all the elements from an ordinary queue into the squeue. Blocks until there's room on the queue, then pushes. May grow queue past maxsize.
val transfer_queue_in_uncond : 'a t -> 'a Core_kernel.Linked_queue.t -> unitval transfer_queue : 'a t -> 'a Core_kernel.Linked_queue.t -> unitTransfers all elements from the squeue to an ordinary queue. The elements remain in order. Waits until at least one element can be transferred.
val transfer_queue_nowait : 'a t -> 'a Core_kernel.Linked_queue.t -> unitTransfers all elements from the squeue to an ordinary queue. The elements remain in order. Does not wait for elements to arrive.
val clear : 'a t -> unitClears the queue
val wait_not_empty : 'a t -> unitwait_not_empty sq waits for something to be available. This is useful if you want to wait, but not take something out. This function is not useful in most cases, but in some complex cases it is essential. For example, if you need to take another lock before you remove something from the queue for processing, you might want to try to take that other lock, and if it fails do something else.
This function is not dangerous, there is just one thing you have to remember if you use it: Just because this function returns doesn't mean that pop will succeed; someone might have gotten there first, so you have to use transfer_queue_nowait if you don't want to block.