tiny_httpd/tiny_httpd/Tiny_httpd_pool/index.html
2023-08-08 16:50:07 -04:00

2 lines
No EOL
2.7 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>Tiny_httpd_pool (tiny_httpd.Tiny_httpd_pool)</title><link rel="stylesheet" href="../../odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 1.5.3"/><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">tiny_httpd</a> &#x00BB; Tiny_httpd_pool</nav><h1>Module <code>Tiny_httpd_pool</code></h1><p>Resource pool.</p><p>This pool is used for buffers. It can be used for other resources but do note that it assumes resources are still reasonably cheap to produce and discard, and will never block waiting for a resource — it's not a good pool for DB connections.</p><dl><dt>since</dt><dd>0.14.</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>Pool of 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 : <span>?&#8288;clear:<span>(<span class="type-var">'a</span> <span>&#45;&gt;</span> unit)</span></span> <span>&#45;&gt;</span> <span>mk_item:<span>(unit <span>&#45;&gt;</span> <span class="type-var">'a</span>)</span></span> <span>&#45;&gt;</span> <span>?&#8288;max_size:int</span> <span>&#45;&gt;</span> unit <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 pool.</p><dl><dt>parameter mk_item</dt><dd><p>produce a new item in case the pool is empty</p></dd></dl><dl><dt>parameter max_size</dt><dd><p>maximum number of item in the pool before we start dropping resources on the floor. This controls resource consumption.</p></dd></dl><dl><dt>parameter clear</dt><dd><p>a function called on items before recycling them.</p></dd></dl></dd></dl><dl><dt class="spec value" id="val-with_resource"><a href="#val-with_resource" class="anchor"></a><code><span class="keyword">val</span> with_resource : <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> <span>&#45;&gt;</span> <span class="type-var">'b</span>)</span> <span>&#45;&gt;</span> <span class="type-var">'b</span></code></dt><dd><p><code>with_resource pool f</code> runs <code>f x</code> with <code>x</code> a resource; when <code>f</code> fails or returns, <code>x</code> is returned to the pool for future reuse.</p></dd></dl></div></body></html>