ocaml-containers/3.2/containers-thread/CCBlockingQueue/index.html
2021-02-01 10:58:00 -05:00

2 lines
No EOL
5.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>CCBlockingQueue (containers-thread.CCBlockingQueue)</title><link rel="stylesheet" href="../../odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 1.5.2"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div class="content"><header><nav><a href="../index.html">Up</a> <a href="../index.html">containers-thread</a> &#x00BB; CCBlockingQueue</nav><h1>Module <code>CCBlockingQueue</code></h1><h2 id="blocking-queue"><a href="#blocking-queue" class="anchor"></a>Blocking Queue</h2><p>This queue has a limited size. Pushing a value on the queue when it is full will block.</p><dl><dt>since</dt><dd>0.16</dd></dl></header><dl><dt class="spec type" id="type-t"><a href="#type-t" class="anchor"></a><code><span class="keyword">type</span> <span>'a t</span></code></dt><dd><p>Safe-thread queue for values of type <code>'a</code></p></dd></dl><dl><dt class="spec value" id="val-create"><a href="#val-create" class="anchor"></a><code><span class="keyword">val</span> create : int <span>&#45;&gt;</span> <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p>Create a new queue of size <code>n</code>. Using <code>n=max_int</code> amounts to using an infinite queue (2^61 items is a lot to fit in memory); using <code>n=1</code> amounts to using a box with 0 or 1 elements inside.</p><dl><dt>raises Invalid_argument</dt><dd><p>if <code>n &lt; 1</code>.</p></dd></dl></dd></dl><dl><dt class="spec value" id="val-push"><a href="#val-push" class="anchor"></a><code><span class="keyword">val</span> push : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span class="type-var">'a</span> <span>&#45;&gt;</span> unit</code></dt><dd><p><code>push q x</code> pushes <code>x</code> into <code>q</code>, blocking if the queue is full.</p></dd></dl><dl><dt class="spec value" id="val-take"><a href="#val-take" class="anchor"></a><code><span class="keyword">val</span> take : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span class="type-var">'a</span></code></dt><dd><p>Take the first element, blocking if needed.</p></dd></dl><dl><dt class="spec value" id="val-push_list"><a href="#val-push_list" class="anchor"></a><code><span class="keyword">val</span> push_list : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> list</span> <span>&#45;&gt;</span> unit</code></dt><dd><p>Push items of the list, one by one.</p></dd></dl><dl><dt class="spec value" id="val-take_list"><a href="#val-take_list" class="anchor"></a><code><span class="keyword">val</span> take_list : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> int <span>&#45;&gt;</span> <span><span class="type-var">'a</span> list</span></code></dt><dd><p><code>take_list n q</code> takes <code>n</code> elements out of <code>q</code>.</p></dd></dl><dl><dt class="spec value" id="val-try_take"><a href="#val-try_take" class="anchor"></a><code><span class="keyword">val</span> try_take : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> option</span></code></dt><dd><p>Take the first element if the queue is not empty, return <code>None</code> otherwise.</p></dd></dl><dl><dt class="spec value" id="val-try_push"><a href="#val-try_push" class="anchor"></a><code><span class="keyword">val</span> try_push : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span class="type-var">'a</span> <span>&#45;&gt;</span> bool</code></dt><dd><p><code>try_push q x</code> pushes <code>x</code> into <code>q</code> if <code>q</code> is not full, in which case it returns <code>true</code>. If it fails because <code>q</code> is full, it returns <code>false</code>.</p></dd></dl><dl><dt class="spec value" id="val-peek"><a href="#val-peek" class="anchor"></a><code><span class="keyword">val</span> peek : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> option</span></code></dt><dd><p><code>peek q</code> returns <code>Some x</code> if <code>x</code> is the first element of <code>q</code>, otherwise it returns <code>None</code>.</p></dd></dl><dl><dt class="spec value" id="val-size"><a href="#val-size" class="anchor"></a><code><span class="keyword">val</span> size : <span><span class="type-var">_</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> int</code></dt><dd><p>Number of elements currently in the queue.</p></dd></dl><dl><dt class="spec value" id="val-capacity"><a href="#val-capacity" class="anchor"></a><code><span class="keyword">val</span> capacity : <span><span class="type-var">_</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> int</code></dt><dd><p>Number of values the queue can hold.</p></dd></dl></div></body></html>