<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>ucommon: ucommon::MappedReuse Class Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.3 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="main.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li class="current"><a href="annotated.html"><span>Data Structures</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li><a href="classes.html"><span>Data Structure Index</span></a></li> <li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Data Fields</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="a00208.html">ucommon</a>::<a class="el" href="a00078.html">MappedReuse</a> </div> </div> <div class="contents"> <h1>ucommon::MappedReuse Class Reference</h1><!-- doxytag: class="ucommon::MappedReuse" --><!-- doxytag: inherits="ucommon::ReusableAllocator,ucommon::MappedMemory" --> <p>Map a reusable allocator over a named shared memory segment. <a href="#_details">More...</a></p> <p><code>#include <<a class="el" href="a00189_source.html">mapped.h</a>></code></p> <div class="dynheader"> Inheritance diagram for ucommon::MappedReuse:</div> <div class="dynsection"> <div class="center"><img src="a00429.png" border="0" usemap="#ucommon_1_1_mapped_reuse_inherit__map" alt="Inheritance graph"/></div> <map name="ucommon_1_1_mapped_reuse_inherit__map" id="ucommon_1_1_mapped_reuse_inherit__map"> <area shape="rect" id="node9" href="a00075.html" title="Template class to map typed reusable objects into shared memory heap." alt="" coords="145,229,428,256"/><area shape="rect" id="node2" href="a00115.html" title="Class for resource bound memory pools between threads." alt="" coords="5,80,288,107"/><area shape="rect" id="node4" href="a00036.html" title="The conditional is a common base for other thread synchronizing classes." alt="" coords="36,5,257,32"/><area shape="rect" id="node6" href="a00077.html" title="Construct or access a named section of memory." alt="" coords="312,80,544,107"/></map> <center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div> <div class="dynheader"> Collaboration diagram for ucommon::MappedReuse:</div> <div class="dynsection"> <div class="center"><img src="a00430.png" border="0" usemap="#ucommon_1_1_mapped_reuse_coll__map" alt="Collaboration graph"/></div> <map name="ucommon_1_1_mapped_reuse_coll__map" id="ucommon_1_1_mapped_reuse_coll__map"> <area shape="rect" id="node2" href="a00115.html" title="Class for resource bound memory pools between threads." alt="" coords="76,267,359,293"/><area shape="rect" id="node4" href="a00036.html" title="The conditional is a common base for other thread synchronizing classes." alt="" coords="5,176,227,203"/><area shape="rect" id="node6" href="a00116.html" title="Reusable objects for forming private heaps." alt="" coords="251,176,501,203"/><area shape="rect" id="node8" href="a00067.html" title="Common base class for all objects that can be formed into a linked list." alt="" coords="260,91,492,117"/><area shape="rect" id="node10" href="a00095.html" title="A common base class for all managed objects." alt="" coords="251,5,501,32"/><area shape="rect" id="node13" href="a00077.html" title="Construct or access a named section of memory." alt="" coords="383,267,615,293"/><area shape="rect" id="node15" href="a00086.html" title="Generic non-recursive exclusive lock class." alt="" coords="639,267,801,293"/><area shape="rect" id="node17" href="a00049.html" title="An exclusive locking protocol interface base." alt="" coords="579,176,861,203"/></map> <center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div> <table border="0" cellpadding="0" cellspacing="0"> <tr><td colspan="2"><h2>Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="a00078.html#a931fcc447ef05b7f7aa791ee13d7a2d7">avail</a> (void)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Check whether there are objects available to be allocated. <a href="#a931fcc447ef05b7f7aa791ee13d7a2d7"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00116.html">ReusableObject</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="a00078.html#a1a7aa3f1c815ce20728fa63110fbdaa5">get</a> (void)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Request a reusable object from the free list or mapped space. <a href="#a1a7aa3f1c815ce20728fa63110fbdaa5"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00116.html">ReusableObject</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="a00078.html#a948ba9cd4b384afb835e845024d399ae">getLocked</a> (void)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Used to get an object from the reuse pool when the mutex lock is already held. <a href="#a948ba9cd4b384afb835e845024d399ae"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00116.html">ReusableObject</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="a00078.html#afd539b11d3ca3bea39d0c5409721fb8a">getTimed</a> (<a class="el" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> timeout)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Request a reusable object from the free list or mapped space. <a href="#afd539b11d3ca3bea39d0c5409721fb8a"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="a00078.html#a1f8892759b7ed3bde5a609e985ec0176">MappedReuse</a> (const char *name, size_t size, unsigned count)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Construct a named memory segment for use with managed fixed size reusable objects. <a href="#a1f8892759b7ed3bde5a609e985ec0176"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="a00078.html#a27e077e50957a71e1360b3c1d44893f1">removeLocked</a> (<a class="el" href="a00116.html">ReusableObject</a> *object)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Used to return an object to the reuse pool when the mutex lock is already held. <a href="#a27e077e50957a71e1360b3c1d44893f1"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00116.html">ReusableObject</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="a00078.html#a84f1421cc5c95bf5c634aeae611e6adb">request</a> (void)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Request a reusable object from the free list or mapped space. <a href="#a84f1421cc5c95bf5c634aeae611e6adb"></a><br/></td></tr> <tr><td colspan="2"><h2>Protected Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa77aac1994be7ff8bb291fc4647831c1"></a><!-- doxytag: member="ucommon::MappedReuse::create" ref="aa77aac1994be7ff8bb291fc4647831c1" args="(const char *fname, unsigned count)" --> void </td><td class="memItemRight" valign="bottom"><b>create</b> (const char *fname, unsigned count)</td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa47d6f64263bc33e2cbedae88f063066"></a><!-- doxytag: member="ucommon::MappedReuse::MappedReuse" ref="aa47d6f64263bc33e2cbedae88f063066" args="(size_t osize)" --> </td><td class="memItemRight" valign="bottom"><b>MappedReuse</b> (size_t osize)</td></tr> </table> <hr/><a name="_details"></a><h2>Detailed Description</h2> <p>Map a reusable allocator over a named shared memory segment. </p> <p>This may be used to form a resource bound fixed size managed heap in shared memory. The request can either be fulfilled from the object reuse pool or from a new section of memory, and if all memory in the segment has been exhausted, it can wait until more objects are returned by another thread to the reuse pool. </p> <dl class="author"><dt><b>Author:</b></dt><dd>David Sugar <<a href="mailto:dyfet@gnutelephony.org">dyfet@gnutelephony.org</a>> </dd></dl> <p>Definition at line <a class="el" href="a00189_source.html#l00193">193</a> of file <a class="el" href="a00189_source.html">mapped.h</a>.</p> <hr/><h2>Constructor & Destructor Documentation</h2> <a class="anchor" id="a1f8892759b7ed3bde5a609e985ec0176"></a><!-- doxytag: member="ucommon::MappedReuse::MappedReuse" ref="a1f8892759b7ed3bde5a609e985ec0176" args="(const char *name, size_t size, unsigned count)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">ucommon::MappedReuse::MappedReuse </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"> <em>name</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">size_t </td> <td class="paramname"> <em>size</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">unsigned </td> <td class="paramname"> <em>count</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Construct a named memory segment for use with managed fixed size reusable objects. </p> <p>The segment is created as writable. There is no read-only version of mapped reuse since the mapped segment can be read by another process directly as a mapped read-only vector. The actual mapped type will be derived from <a class="el" href="a00116.html" title="Reusable objects for forming private heaps.">ReusableObject</a> to meet the needs of the reusable allocator. The template version should be used to assure type correctness rather than using this class directly. </p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>name</em> </td><td>of shared memory segment. </td></tr> <tr><td valign="top"></td><td valign="top"><em>size</em> </td><td>of the object type being mapped. </td></tr> <tr><td valign="top"></td><td valign="top"><em>count</em> </td><td>of the maximum number of active mapped objects. </td></tr> </table> </dd> </dl> </div> </div> <hr/><h2>Member Function Documentation</h2> <a class="anchor" id="a931fcc447ef05b7f7aa791ee13d7a2d7"></a><!-- doxytag: member="ucommon::MappedReuse::avail" ref="a931fcc447ef05b7f7aa791ee13d7a2d7" args="(void)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool ucommon::MappedReuse::avail </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Check whether there are objects available to be allocated. </p> <dl class="return"><dt><b>Returns:</b></dt><dd>true if objects are available. </dd></dl> </div> </div> <a class="anchor" id="a1a7aa3f1c815ce20728fa63110fbdaa5"></a><!-- doxytag: member="ucommon::MappedReuse::get" ref="a1a7aa3f1c815ce20728fa63110fbdaa5" args="(void)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="a00116.html">ReusableObject</a>* ucommon::MappedReuse::get </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Request a reusable object from the free list or mapped space. </p> <p>This method blocks until an object becomes available. </p> <dl class="return"><dt><b>Returns:</b></dt><dd>free object. </dd></dl> <p>Reimplemented in <a class="el" href="a00075.html#a904a33faf77e98d157dedb925f41616b">ucommon::mapped_reuse< T ></a>.</p> </div> </div> <a class="anchor" id="a948ba9cd4b384afb835e845024d399ae"></a><!-- doxytag: member="ucommon::MappedReuse::getLocked" ref="a948ba9cd4b384afb835e845024d399ae" args="(void)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="a00116.html">ReusableObject</a>* ucommon::MappedReuse::getLocked </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Used to get an object from the reuse pool when the mutex lock is already held. </p> <dl class="return"><dt><b>Returns:</b></dt><dd>object from pool or NULL if exhausted. </dd></dl> <p>Reimplemented in <a class="el" href="a00075.html#aa0a274db7a691c653576a65b26dda8bd">ucommon::mapped_reuse< T ></a>.</p> </div> </div> <a class="anchor" id="afd539b11d3ca3bea39d0c5409721fb8a"></a><!-- doxytag: member="ucommon::MappedReuse::getTimed" ref="afd539b11d3ca3bea39d0c5409721fb8a" args="(timeout_t timeout)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="a00116.html">ReusableObject</a>* ucommon::MappedReuse::getTimed </td> <td>(</td> <td class="paramtype"><a class="el" href="a00194.html#af412159e5cef839836a5e7b19ee75d1c">timeout_t</a> </td> <td class="paramname"> <em>timeout</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Request a reusable object from the free list or mapped space. </p> <p>This method blocks until an object becomes available or the timeout has expired. </p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>timeout</em> </td><td>to wait in milliseconds. </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>free object or NULL if timeout. </dd></dl> <p>Reimplemented in <a class="el" href="a00075.html#add23eebb23e599a77cad165b997be059">ucommon::mapped_reuse< T ></a>.</p> </div> </div> <a class="anchor" id="a27e077e50957a71e1360b3c1d44893f1"></a><!-- doxytag: member="ucommon::MappedReuse::removeLocked" ref="a27e077e50957a71e1360b3c1d44893f1" args="(ReusableObject *object)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void ucommon::MappedReuse::removeLocked </td> <td>(</td> <td class="paramtype"><a class="el" href="a00116.html">ReusableObject</a> * </td> <td class="paramname"> <em>object</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Used to return an object to the reuse pool when the mutex lock is already held. </p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>object</em> </td><td>being returned. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="a84f1421cc5c95bf5c634aeae611e6adb"></a><!-- doxytag: member="ucommon::MappedReuse::request" ref="a84f1421cc5c95bf5c634aeae611e6adb" args="(void)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="a00116.html">ReusableObject</a>* ucommon::MappedReuse::request </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Request a reusable object from the free list or mapped space. </p> <dl class="return"><dt><b>Returns:</b></dt><dd>free object or NULL if pool is exhausted. </dd></dl> <p>Reimplemented in <a class="el" href="a00075.html#a3e38909be1310042321e738bb94ea16c">ucommon::mapped_reuse< T ></a>.</p> </div> </div> <hr/>The documentation for this class was generated from the following file:<ul> <li>ucommon/<a class="el" href="a00189_source.html">mapped.h</a></li> </ul> </div> <hr class="footer"/><address style="text-align: right;"><small>Generated on Thu Jul 14 16:39:44 2011 for ucommon by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address> </body> </html>