mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-05 19:00:31 -05:00
244 lines
No EOL
17 KiB
HTML
244 lines
No EOL
17 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<link rel="stylesheet" href="style.css" type="text/css">
|
|
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
|
<link rel="Start" href="index.html">
|
|
<link rel="Up" href="CCPool.Make.html">
|
|
<link title="Index of types" rel=Appendix href="index_types.html">
|
|
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
|
|
<link title="Index of values" rel=Appendix href="index_values.html">
|
|
<link title="Index of class methods" rel=Appendix href="index_methods.html">
|
|
<link title="Index of class types" rel=Appendix href="index_class_types.html">
|
|
<link title="Index of modules" rel=Appendix href="index_modules.html">
|
|
<link title="Index of module types" rel=Appendix href="index_module_types.html">
|
|
<link title="CCVector" rel="Chapter" href="CCVector.html">
|
|
<link title="CCPrint" rel="Chapter" href="CCPrint.html">
|
|
<link title="CCError" rel="Chapter" href="CCError.html">
|
|
<link title="CCHeap" rel="Chapter" href="CCHeap.html">
|
|
<link title="CCList" rel="Chapter" href="CCList.html">
|
|
<link title="CCOpt" rel="Chapter" href="CCOpt.html">
|
|
<link title="CCPair" rel="Chapter" href="CCPair.html">
|
|
<link title="CCFun" rel="Chapter" href="CCFun.html">
|
|
<link title="CCHash" rel="Chapter" href="CCHash.html">
|
|
<link title="CCInt" rel="Chapter" href="CCInt.html">
|
|
<link title="CCBool" rel="Chapter" href="CCBool.html">
|
|
<link title="CCFloat" rel="Chapter" href="CCFloat.html">
|
|
<link title="CCArray" rel="Chapter" href="CCArray.html">
|
|
<link title="CCRef" rel="Chapter" href="CCRef.html">
|
|
<link title="CCSet" rel="Chapter" href="CCSet.html">
|
|
<link title="CCOrd" rel="Chapter" href="CCOrd.html">
|
|
<link title="CCRandom" rel="Chapter" href="CCRandom.html">
|
|
<link title="CCString" rel="Chapter" href="CCString.html">
|
|
<link title="CCHashtbl" rel="Chapter" href="CCHashtbl.html">
|
|
<link title="CCMap" rel="Chapter" href="CCMap.html">
|
|
<link title="CCFormat" rel="Chapter" href="CCFormat.html">
|
|
<link title="CCIO" rel="Chapter" href="CCIO.html">
|
|
<link title="CCInt64" rel="Chapter" href="CCInt64.html">
|
|
<link title="CCChar" rel="Chapter" href="CCChar.html">
|
|
<link title="CCResult" rel="Chapter" href="CCResult.html">
|
|
<link title="Containers" rel="Chapter" href="Containers.html">
|
|
<link title="CCKTree" rel="Chapter" href="CCKTree.html">
|
|
<link title="CCKList" rel="Chapter" href="CCKList.html">
|
|
<link title="CCLazy_list" rel="Chapter" href="CCLazy_list.html">
|
|
<link title="CCMultiMap" rel="Chapter" href="CCMultiMap.html">
|
|
<link title="CCMultiSet" rel="Chapter" href="CCMultiSet.html">
|
|
<link title="CCTrie" rel="Chapter" href="CCTrie.html">
|
|
<link title="CCFlatHashtbl" rel="Chapter" href="CCFlatHashtbl.html">
|
|
<link title="CCCache" rel="Chapter" href="CCCache.html">
|
|
<link title="CCPersistentHashtbl" rel="Chapter" href="CCPersistentHashtbl.html">
|
|
<link title="CCDeque" rel="Chapter" href="CCDeque.html">
|
|
<link title="CCFQueue" rel="Chapter" href="CCFQueue.html">
|
|
<link title="CCBV" rel="Chapter" href="CCBV.html">
|
|
<link title="CCMixtbl" rel="Chapter" href="CCMixtbl.html">
|
|
<link title="CCMixmap" rel="Chapter" href="CCMixmap.html">
|
|
<link title="CCRingBuffer" rel="Chapter" href="CCRingBuffer.html">
|
|
<link title="CCIntMap" rel="Chapter" href="CCIntMap.html">
|
|
<link title="CCPersistentArray" rel="Chapter" href="CCPersistentArray.html">
|
|
<link title="CCMixset" rel="Chapter" href="CCMixset.html">
|
|
<link title="CCHashconsedSet" rel="Chapter" href="CCHashconsedSet.html">
|
|
<link title="CCGraph" rel="Chapter" href="CCGraph.html">
|
|
<link title="CCHashSet" rel="Chapter" href="CCHashSet.html">
|
|
<link title="CCBitField" rel="Chapter" href="CCBitField.html">
|
|
<link title="CCHashTrie" rel="Chapter" href="CCHashTrie.html">
|
|
<link title="CCBloom" rel="Chapter" href="CCBloom.html">
|
|
<link title="CCWBTree" rel="Chapter" href="CCWBTree.html">
|
|
<link title="CCRAL" rel="Chapter" href="CCRAL.html">
|
|
<link title="CCAllocCache" rel="Chapter" href="CCAllocCache.html">
|
|
<link title="CCImmutArray" rel="Chapter" href="CCImmutArray.html">
|
|
<link title="CCHet" rel="Chapter" href="CCHet.html">
|
|
<link title="Containers_string" rel="Chapter" href="Containers_string.html">
|
|
<link title="CCKMP" rel="Chapter" href="CCKMP.html">
|
|
<link title="CCLevenshtein" rel="Chapter" href="CCLevenshtein.html">
|
|
<link title="CCApp_parse" rel="Chapter" href="CCApp_parse.html">
|
|
<link title="CCParse" rel="Chapter" href="CCParse.html">
|
|
<link title="CCBigstring" rel="Chapter" href="CCBigstring.html">
|
|
<link title="CCArray1" rel="Chapter" href="CCArray1.html">
|
|
<link title="CCPool" rel="Chapter" href="CCPool.html">
|
|
<link title="CCLock" rel="Chapter" href="CCLock.html">
|
|
<link title="CCSemaphore" rel="Chapter" href="CCSemaphore.html">
|
|
<link title="CCThread" rel="Chapter" href="CCThread.html">
|
|
<link title="CCBlockingQueue" rel="Chapter" href="CCBlockingQueue.html">
|
|
<link title="CCTimer" rel="Chapter" href="CCTimer.html">
|
|
<link title="Containers_advanced" rel="Chapter" href="Containers_advanced.html">
|
|
<link title="CCLinq" rel="Chapter" href="CCLinq.html">
|
|
<link title="CCBatch" rel="Chapter" href="CCBatch.html">
|
|
<link title="CCCat" rel="Chapter" href="CCCat.html">
|
|
<link title="CCMonadIO" rel="Chapter" href="CCMonadIO.html">
|
|
<link title="Containers_io_is_deprecated" rel="Chapter" href="Containers_io_is_deprecated.html">
|
|
<link title="CCUnix" rel="Chapter" href="CCUnix.html">
|
|
<link title="CCSexp" rel="Chapter" href="CCSexp.html">
|
|
<link title="CCSexpM" rel="Chapter" href="CCSexpM.html"><link title="Constructors" rel="Section" href="#2_Constructors">
|
|
<link title="Basics" rel="Section" href="#2_Basics">
|
|
<link title="Combinators" rel="Section" href="#2_Combinators">
|
|
<title>Containers doc : CCPool.Make.Fut</title>
|
|
</head>
|
|
<body>
|
|
<div class="navbar"> <a class="up" href="CCPool.Make.html" title="CCPool.Make">Up</a>
|
|
</div>
|
|
<h1>Module <a href="type_CCPool.Make.Fut.html">CCPool.Make.Fut</a></h1>
|
|
|
|
<pre><span class="keyword">module</span> Fut: <code class="code"><span class="keyword">sig</span></code> <a href="CCPool.Make.Fut.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info module top">
|
|
<h6 id="6_Futures">Futures</h6>
|
|
<p>
|
|
|
|
The futures are registration points for callbacks, storing a <a href="CCPool.Make.Fut.html#VALstate"><code class="code"><span class="constructor">CCPool</span>.<span class="constructor">Make</span>.<span class="constructor">Fut</span>.state</code></a>,
|
|
that are executed in the pool using <a href="CCPool.Make.html#VALrun"><code class="code"><span class="constructor">CCPool</span>.<span class="constructor">Make</span>.run</code></a>.<br>
|
|
</div>
|
|
<hr width="100%">
|
|
|
|
<pre><span id="TYPEt"><span class="keyword">type</span> <code class="type">'a</code> t</span> </pre>
|
|
<div class="info ">
|
|
A future value of type 'a<br>
|
|
</div>
|
|
|
|
|
|
<pre><span id="TYPEfuture"><span class="keyword">type</span> <code class="type">'a</code> future</span> = <code class="type">'a <a href="CCPool.Make.Fut.html#TYPEt">t</a></code> </pre>
|
|
|
|
<br>
|
|
<h2 id="2_Constructors">Constructors</h2><br>
|
|
|
|
<pre><span id="VALreturn"><span class="keyword">val</span> return</span> : <code class="type">'a -> 'a <a href="CCPool.Make.Fut.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Future that is already computed<br>
|
|
</div>
|
|
|
|
<pre><span id="VALfail"><span class="keyword">val</span> fail</span> : <code class="type">exn -> 'a <a href="CCPool.Make.Fut.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Future that fails immediately<br>
|
|
</div>
|
|
|
|
<pre><span id="VALmake"><span class="keyword">val</span> make</span> : <code class="type">(unit -> 'a) -> 'a <a href="CCPool.Make.Fut.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Create a future, representing a value that will be computed by
|
|
the function. If the function raises, the future will fail.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALmake1"><span class="keyword">val</span> make1</span> : <code class="type">('a -> 'b) -> 'a -> 'b <a href="CCPool.Make.Fut.html#TYPEt">t</a></code></pre>
|
|
<pre><span id="VALmake2"><span class="keyword">val</span> make2</span> : <code class="type">('a -> 'b -> 'c) -> 'a -> 'b -> 'c <a href="CCPool.Make.Fut.html#TYPEt">t</a></code></pre><br>
|
|
<h2 id="2_Basics">Basics</h2><br>
|
|
|
|
<pre><span id="VALget"><span class="keyword">val</span> get</span> : <code class="type">'a <a href="CCPool.Make.Fut.html#TYPEt">t</a> -> 'a</code></pre><div class="info ">
|
|
Blocking get: wait for the future to be evaluated, and get the value,
|
|
or the exception that failed the future is returned.
|
|
raise e if the future failed with e<br>
|
|
</div>
|
|
|
|
<pre><span id="VALstate"><span class="keyword">val</span> state</span> : <code class="type">'a <a href="CCPool.Make.Fut.html#TYPEt">t</a> -> 'a <a href="CCPool.html#TYPEstate">CCPool.state</a></code></pre><div class="info ">
|
|
State of the future<br>
|
|
</div>
|
|
|
|
<pre><span id="VALis_done"><span class="keyword">val</span> is_done</span> : <code class="type">'a <a href="CCPool.Make.Fut.html#TYPEt">t</a> -> bool</code></pre><div class="info ">
|
|
Is the future evaluated (success/failure)?<br>
|
|
</div>
|
|
<br>
|
|
<h2 id="2_Combinators">Combinators</h2><br>
|
|
|
|
<pre><span id="VALon_success"><span class="keyword">val</span> on_success</span> : <code class="type">'a <a href="CCPool.Make.Fut.html#TYPEt">t</a> -> ('a -> unit) -> unit</code></pre><div class="info ">
|
|
Attach a handler to be called upon success.
|
|
The handler should not call functions on the future.
|
|
Might be evaluated now if the future is already done.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALon_failure"><span class="keyword">val</span> on_failure</span> : <code class="type">'a <a href="CCPool.Make.Fut.html#TYPEt">t</a> -> (exn -> unit) -> unit</code></pre><div class="info ">
|
|
Attach a handler to be called upon failure.
|
|
The handler should not call any function on the future.
|
|
Might be evaluated now if the future is already done.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALon_finish"><span class="keyword">val</span> on_finish</span> : <code class="type">'a <a href="CCPool.Make.Fut.html#TYPEt">t</a> -> ('a <a href="CCPool.html#TYPEstate">CCPool.state</a> -> unit) -> unit</code></pre><div class="info ">
|
|
Attach a handler to be called when the future is evaluated.
|
|
The handler should not call functions on the future.
|
|
Might be evaluated now if the future is already done.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALflat_map"><span class="keyword">val</span> flat_map</span> : <code class="type">('a -> 'b <a href="CCPool.Make.Fut.html#TYPEt">t</a>) -> 'a <a href="CCPool.Make.Fut.html#TYPEt">t</a> -> 'b <a href="CCPool.Make.Fut.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Monadic combination of futures<br>
|
|
</div>
|
|
|
|
<pre><span id="VALand_then"><span class="keyword">val</span> and_then</span> : <code class="type">'a <a href="CCPool.Make.Fut.html#TYPEt">t</a> -><br> (unit -> 'b <a href="CCPool.Make.Fut.html#TYPEt">t</a>) -> 'b <a href="CCPool.Make.Fut.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Wait for the first future to succeed, then launch the second<br>
|
|
</div>
|
|
|
|
<pre><span id="VALsequence_a"><span class="keyword">val</span> sequence_a</span> : <code class="type">'a <a href="CCPool.Make.Fut.html#TYPEt">t</a> array -> 'a array <a href="CCPool.Make.Fut.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Future that waits for all previous futures to terminate. If any future
|
|
in the array fails, <code class="code">sequence_a l</code> fails too.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALmap_a"><span class="keyword">val</span> map_a</span> : <code class="type">('a -> 'b <a href="CCPool.Make.Fut.html#TYPEt">t</a>) -> 'a array -> 'b array <a href="CCPool.Make.Fut.html#TYPEt">t</a></code></pre><div class="info ">
|
|
<code class="code">map_l f a</code> maps <code class="code">f</code> on every element of <code class="code">a</code>, and will return
|
|
the array of every result if all calls succeed, or an error otherwise.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALsequence_l"><span class="keyword">val</span> sequence_l</span> : <code class="type">'a <a href="CCPool.Make.Fut.html#TYPEt">t</a> list -> 'a list <a href="CCPool.Make.Fut.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Future that waits for all previous futures to terminate. If any future
|
|
in the list fails, <code class="code">sequence_l l</code> fails too.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALmap_l"><span class="keyword">val</span> map_l</span> : <code class="type">('a -> 'b <a href="CCPool.Make.Fut.html#TYPEt">t</a>) -> 'a list -> 'b list <a href="CCPool.Make.Fut.html#TYPEt">t</a></code></pre><div class="info ">
|
|
<code class="code">map_l f l</code> maps <code class="code">f</code> on every element of <code class="code">l</code>, and will return
|
|
the list of every result if all calls succeed, or an error otherwise.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALchoose_a"><span class="keyword">val</span> choose_a</span> : <code class="type">'a <a href="CCPool.Make.Fut.html#TYPEt">t</a> array -> 'a <a href="CCPool.Make.Fut.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Choose among those futures (the first to terminate). Behaves like
|
|
the first future that terminates, by failing if the future fails<br>
|
|
</div>
|
|
|
|
<pre><span id="VALchoose_l"><span class="keyword">val</span> choose_l</span> : <code class="type">'a <a href="CCPool.Make.Fut.html#TYPEt">t</a> list -> 'a <a href="CCPool.Make.Fut.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Choose among those futures (the first to terminate). Behaves like
|
|
the first future that terminates, by failing if the future fails<br>
|
|
</div>
|
|
|
|
<pre><span id="VALmap"><span class="keyword">val</span> map</span> : <code class="type">('a -> 'b) -> 'a <a href="CCPool.Make.Fut.html#TYPEt">t</a> -> 'b <a href="CCPool.Make.Fut.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Maps the value inside the future. The function doesn't run in its
|
|
own task; if it can take time, use <a href="CCPool.Make.Fut.html#VALflat_map"><code class="code"><span class="constructor">CCPool</span>.<span class="constructor">Make</span>.<span class="constructor">Fut</span>.flat_map</code></a> or <a href="CCPool.Make.Fut.html#VALmap_async"><code class="code"><span class="constructor">CCPool</span>.<span class="constructor">Make</span>.<span class="constructor">Fut</span>.map_async</code></a><br>
|
|
</div>
|
|
|
|
<pre><span id="VALmap_async"><span class="keyword">val</span> map_async</span> : <code class="type">('a -> 'b) -> 'a <a href="CCPool.Make.Fut.html#TYPEt">t</a> -> 'b <a href="CCPool.Make.Fut.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Maps the value inside the future, to be computed in a separated job.<br>
|
|
</div>
|
|
|
|
<pre><span id="VALapp"><span class="keyword">val</span> app</span> : <code class="type">('a -> 'b) <a href="CCPool.Make.Fut.html#TYPEt">t</a> -> 'a <a href="CCPool.Make.Fut.html#TYPEt">t</a> -> 'b <a href="CCPool.Make.Fut.html#TYPEt">t</a></code></pre><div class="info ">
|
|
<code class="code">app f x</code> applies the result of <code class="code">f</code> to the result of <code class="code">x</code><br>
|
|
</div>
|
|
|
|
<pre><span id="VALapp_async"><span class="keyword">val</span> app_async</span> : <code class="type">('a -> 'b) <a href="CCPool.Make.Fut.html#TYPEt">t</a> -> 'a <a href="CCPool.Make.Fut.html#TYPEt">t</a> -> 'b <a href="CCPool.Make.Fut.html#TYPEt">t</a></code></pre><div class="info ">
|
|
<code class="code">app f x</code> applies the result of <code class="code">f</code> to the result of <code class="code">x</code>, in
|
|
a separated job scheduled in the pool<br>
|
|
</div>
|
|
|
|
<pre><span id="VALsleep"><span class="keyword">val</span> sleep</span> : <code class="type">float -> unit <a href="CCPool.Make.Fut.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Future that returns with success in the given amount of seconds. Blocks
|
|
the thread! If you need to wait on many events, consider
|
|
using <a href="CCTimer.html"><code class="code"><span class="constructor">CCTimer</span></code></a>.<br>
|
|
</div>
|
|
|
|
<pre><span class="keyword">module</span> <a href="CCPool.Make.Fut.Infix.html">Infix</a>: <code class="code"><span class="keyword">sig</span></code> <a href="CCPool.Make.Fut.Infix.html">..</a> <code class="code"><span class="keyword">end</span></code></pre>
|
|
<pre><span id="VAL(>>=)"><span class="keyword">val</span> (>>=)</span> : <code class="type">'a <a href="CCPool.Make.Fut.html#TYPEt">t</a> -> ('a -> 'b <a href="CCPool.Make.Fut.html#TYPEt">t</a>) -> 'b <a href="CCPool.Make.Fut.html#TYPEt">t</a></code></pre>
|
|
<pre><span id="VAL(>>)"><span class="keyword">val</span> (>>)</span> : <code class="type">'a <a href="CCPool.Make.Fut.html#TYPEt">t</a> -><br> (unit -> 'b <a href="CCPool.Make.Fut.html#TYPEt">t</a>) -> 'b <a href="CCPool.Make.Fut.html#TYPEt">t</a></code></pre>
|
|
<pre><span id="VAL(>|=)"><span class="keyword">val</span> (>|=)</span> : <code class="type">'a <a href="CCPool.Make.Fut.html#TYPEt">t</a> -> ('a -> 'b) -> 'b <a href="CCPool.Make.Fut.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Alias to <a href="CCPool.Make.Fut.html#VALmap"><code class="code"><span class="constructor">CCPool</span>.<span class="constructor">Make</span>.<span class="constructor">Fut</span>.map</code></a><br>
|
|
</div>
|
|
|
|
<pre><span id="VAL(<*>)"><span class="keyword">val</span> (<*>)</span> : <code class="type">('a -> 'b) <a href="CCPool.Make.Fut.html#TYPEt">t</a> -> 'a <a href="CCPool.Make.Fut.html#TYPEt">t</a> -> 'b <a href="CCPool.Make.Fut.html#TYPEt">t</a></code></pre><div class="info ">
|
|
Alias to <a href="CCPool.Make.Fut.html#VALapp"><code class="code"><span class="constructor">CCPool</span>.<span class="constructor">Make</span>.<span class="constructor">Fut</span>.app</code></a><br>
|
|
</div>
|
|
</body></html> |