module Squeue: Squeue
type 'a
t
val create : int -> 'a t
create maxsize
returns a synchronized queue bounded to have no more than
maxsize
elements.val push : 'a t -> 'a -> unit
val push_uncond : 'a t -> 'a -> unit
val push_or_drop : 'a t -> 'a -> bool
val length : 'a t -> int
val pop : 'a t -> 'a
val lpop : 'a t -> 'a * int
val transfer_queue_in : 'a t -> 'a Core_kernel.Std.Queue.t -> unit
val transfer_queue_in_uncond : 'a t -> 'a Core_kernel.Std.Queue.t -> unit
val transfer_queue : 'a t -> 'a Core_kernel.Std.Queue.t -> unit
val transfer_queue_nowait : 'a t -> 'a Core_kernel.Std.Queue.t -> unit
val clear : 'a t -> unit
val wait_not_empty : 'a t -> unit
wait_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 you might 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.
val sexp_of_t : ('a -> Sexplib.Sexp.t) -> 'a t -> Sexplib.Sexp.t
create maxsize
returns a synchronized queue bounded to have no more than
maxsize
elements.wait_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 you might 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.