<?xml version='1.0'?>
<html xmlns='http://www.w3.org/1999/xhtml'
      xmlns:math='http://www.w3.org/1998/Math/MathML'
>
<head>
<title>A Fast Multi-Threading Memory Allocator</title>
<meta name="description" id="description" content="A Fast Multi-Threading Memory Allocator"/>
<meta name="keywords" id="keywords" content=" multi-threading memory allocation "/>
<style type='text/css'>
body { color : black }
body { background-color : white }
A:link { color : blue }
A:visited { color : purple }
A:active { color : purple }
</style>
<script type='text/javascript' language='JavaScript' src='_thread_alloc_xml.js'>
</script>
</head>
<body>
<table><tr>
<td>
<a href="http://www.coin-or.org/CppAD/" target="_top"><img border="0" src="_image.gif"/></a>
</td>
<td><a href="vector_bool.cpp.xml" target="_top">Prev</a>
</td><td><a href="thread_alloc.cpp.xml" target="_top">Next</a>
</td><td>
<select onchange='choose_across0(this)'>
<option>Index-&gt;</option>
<option>contents</option>
<option>reference</option>
<option>index</option>
<option>search</option>
<option>external</option>
</select>
</td>
<td>
<select onchange='choose_up0(this)'>
<option>Up-&gt;</option>
<option>CppAD</option>
<option>library</option>
<option>thread_alloc</option>
</select>
</td>
<td>
<select onchange='choose_down2(this)'>
<option>CppAD-&gt;</option>
<option>Install</option>
<option>Introduction</option>
<option>AD</option>
<option>ADFun</option>
<option>preprocessor</option>
<option>multi_thread</option>
<option>library</option>
<option>ipopt_solve</option>
<option>Example</option>
<option>speed</option>
<option>Appendix</option>
</select>
</td>
<td>
<select onchange='choose_down1(this)'>
<option>library-&gt;</option>
<option>ErrorHandler</option>
<option>NearEqual</option>
<option>speed_test</option>
<option>SpeedTest</option>
<option>time_test</option>
<option>NumericType</option>
<option>CheckNumericType</option>
<option>SimpleVector</option>
<option>CheckSimpleVector</option>
<option>nan</option>
<option>pow_int</option>
<option>Poly</option>
<option>LuDetAndSolve</option>
<option>RombergOne</option>
<option>RombergMul</option>
<option>Runge45</option>
<option>Rosen34</option>
<option>OdeErrControl</option>
<option>OdeGear</option>
<option>OdeGearControl</option>
<option>CppAD_vector</option>
<option>thread_alloc</option>
<option>index_sort</option>
<option>BenderQuad</option>
<option>opt_val_hes</option>
<option>LuRatio</option>
</select>
</td>
<td>
<select onchange='choose_down0(this)'>
<option>thread_alloc-&gt;</option>
<option>thread_alloc.cpp</option>
<option>ta_parallel_setup</option>
<option>ta_num_threads</option>
<option>ta_in_parallel</option>
<option>ta_thread_num</option>
<option>ta_get_memory</option>
<option>ta_return_memory</option>
<option>ta_free_available</option>
<option>ta_hold_memory</option>
<option>ta_inuse</option>
<option>ta_available</option>
<option>ta_create_array</option>
<option>ta_delete_array</option>
<option>ta_free_all</option>
</select>
</td>
<td>
<select onchange='choose_current0(this)'>
<option>Headings-&gt;</option>
<option>Syntax</option>
<option>Purpose</option>
<option>Include</option>
<option>Contents</option>
</select>
</td>
</tr></table><br/>



<center><b><big><big>A Fast Multi-Threading Memory Allocator</big></big></b></center>
<br/>
<b><big><a name="Syntax" id="Syntax">Syntax</a></big></b>

<code><font color="blue"><br/>
# include &lt;cppad/thread_alloc.hpp&gt;</font></code>

<br/>
<br/>
<b><big><a name="Purpose" id="Purpose">Purpose</a></big></b>
<br/>
The C++ <code><font color="blue">new</font></code> and <code><font color="blue">delete</font></code> operators are thread safe,
but this means that a thread may have to wait for a lock on these operations.
Once memory is obtained for a thread, the <code><font color="blue">thread_alloc</font></code> memory
allocator keeps that memory <a href="ta_available.xml" target="_top"><span style='white-space: nowrap'>available</span></a>
 for the thread so that
it can be re-used without waiting for a lock.
All the CppAD memory allocations use this utility. 
The <a href="ta_free_available.xml" target="_top"><span style='white-space: nowrap'>free_available</span></a>
 function should be used to return memory
to the system (once it is no longer required by a thread).

<br/>
<br/>
<b><big><a name="Include" id="Include">Include</a></big></b>
<br/>
The routines in sections below are defined by <code><font color="blue">cppad/thread_alloc.hpp</font></code>.
This file is included by
<code><font color="blue">cppad/cppad.hpp</font></code>, but it can also be included separately with out
the rest of the <code><font color="blue">CppAD</font></code>.

<br/>
<br/>
<b><big><a name="Contents" id="Contents">Contents</a></big></b>
<br/>
<table>
<tr><td><a href="thread_alloc.cpp.xml" target="_top">thread_alloc.cpp</a></td><td>Fast&#xA0;Multi-Threading&#xA0;Memory&#xA0;Allocator:&#xA0;Example&#xA0;and&#xA0;Test</td></tr><tr><td><a href="ta_parallel_setup.xml" target="_top">ta_parallel_setup</a></td><td>Setup&#xA0;thread_alloc&#xA0;For&#xA0;Use&#xA0;in&#xA0;Multi-Threading&#xA0;Environment</td></tr><tr><td><a href="ta_num_threads.xml" target="_top">ta_num_threads</a></td><td>Get&#xA0;Number&#xA0;of&#xA0;Threads</td></tr><tr><td><a href="ta_in_parallel.xml" target="_top">ta_in_parallel</a></td><td>Is&#xA0;The&#xA0;Current&#xA0;Execution&#xA0;in&#xA0;Parallel&#xA0;Mode</td></tr><tr><td><a href="ta_thread_num.xml" target="_top">ta_thread_num</a></td><td>Get&#xA0;the&#xA0;Current&#xA0;Thread&#xA0;Number</td></tr><tr><td><a href="ta_get_memory.xml" target="_top">ta_get_memory</a></td><td>Get&#xA0;At&#xA0;Least&#xA0;A&#xA0;Specified&#xA0;Amount&#xA0;of&#xA0;Memory</td></tr><tr><td><a href="ta_return_memory.xml" target="_top">ta_return_memory</a></td><td>Return&#xA0;Memory&#xA0;to&#xA0;thread_alloc</td></tr><tr><td><a href="ta_free_available.xml" target="_top">ta_free_available</a></td><td>Free&#xA0;Memory&#xA0;Currently&#xA0;Available&#xA0;for&#xA0;Quick&#xA0;Use&#xA0;by&#xA0;a&#xA0;Thread</td></tr><tr><td><a href="ta_hold_memory.xml" target="_top">ta_hold_memory</a></td><td>Control&#xA0;When&#xA0;Thread&#xA0;Alloc&#xA0;Retains&#xA0;Memory&#xA0;For&#xA0;Future&#xA0;Use</td></tr><tr><td><a href="ta_inuse.xml" target="_top">ta_inuse</a></td><td>Amount&#xA0;of&#xA0;Memory&#xA0;a&#xA0;Thread&#xA0;is&#xA0;Currently&#xA0;Using</td></tr><tr><td><a href="ta_available.xml" target="_top">ta_available</a></td><td>Amount&#xA0;of&#xA0;Memory&#xA0;Available&#xA0;for&#xA0;Quick&#xA0;Use&#xA0;by&#xA0;a&#xA0;Thread</td></tr><tr><td><a href="ta_create_array.xml" target="_top">ta_create_array</a></td><td>Allocate&#xA0;An&#xA0;Array&#xA0;and&#xA0;Call&#xA0;Default&#xA0;Constructor&#xA0;for&#xA0;its&#xA0;Elements</td></tr><tr><td><a href="ta_delete_array.xml" target="_top">ta_delete_array</a></td><td>Deallocate&#xA0;An&#xA0;Array&#xA0;and&#xA0;Call&#xA0;Destructor&#xA0;for&#xA0;its&#xA0;Elements</td></tr><tr><td><a href="ta_free_all.xml" target="_top">ta_free_all</a></td><td>Free&#xA0;All&#xA0;Memory&#xA0;That&#xA0;Was&#xA0;Allocated&#xA0;for&#xA0;Use&#xA0;by&#xA0;thread_alloc</td></tr></table>
<hr/>Input File: omh/thread_alloc.omh

</body>
</html>
