package containers

  1. Overview
  2. Docs
A modular, clean and powerful extension of the OCaml standard library

Install

Dune Dependency

Authors

Maintainers

Sources

v2.8.1.tar.gz
md5=d84e09c5d0abc501aa17cd502e31a038
sha512=8b832f4ada6035e80d81be0cfb7bdffb695ec67d465ed6097a144019e2b8a8f909095e78019c3da2d8181cc3cd730cd48f7519e87d3162442562103b7f36aabb

doc/containers.thread/CCBlockingQueue/index.html

Module CCBlockingQueueSource

Blocking Queue

This queue has a limited size. Pushing a value on the queue when it is full will block.

  • since 0.16
Sourcetype 'a t

Safe-thread queue for values of type 'a

Sourceval create : int -> 'a t

Create a new queue of size n. Using n=max_int amounts to using an infinite queue (2^61 items is a lot to fit in memory); using n=1 amounts to using a box with 0 or 1 elements inside.

Sourceval push : 'a t -> 'a -> unit

push q x pushes x into q, blocking if the queue is full.

Sourceval take : 'a t -> 'a

Take the first element, blocking if needed.

Sourceval push_list : 'a t -> 'a list -> unit

Push items of the list, one by one.

Sourceval take_list : 'a t -> int -> 'a list

take_list n q takes n elements out of q.

Sourceval try_take : 'a t -> 'a option

Take the first element if the queue is not empty, return None otherwise.

Sourceval try_push : 'a t -> 'a -> bool

try_push q x pushes x into q if q is not full, in which case it returns true. If it fails because q is full, it returns false.

Sourceval peek : 'a t -> 'a option

peek q returns Some x if x is the first element of q, otherwise it returns None.

Sourceval size : _ t -> int

Number of elements currently in the queue.

Sourceval capacity : _ t -> int

Number of values the queue can hold.

OCaml

Innovation. Community. Security.

On This Page
  1. Blocking Queue