<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>Barry: Barry::DataQueue Class Reference</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.5.6 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li class="current"><a href="classes.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="classes.html"><span>Alphabetical List</span></a></li> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="namespaceBarry.html">Barry</a>::<a class="el" href="classBarry_1_1DataQueue.html">DataQueue</a> </div> </div> <div class="contents"> <h1>Barry::DataQueue Class Reference</h1><!-- doxytag: class="Barry::DataQueue" --><code>#include <<a class="el" href="dataqueue_8h-source.html">dataqueue.h</a>></code> <p> <p> <a href="classBarry_1_1DataQueue-members.html">List of all members.</a><hr><a name="_details"></a><h2>Detailed Description</h2> This class provides a thread aware fifo queue for Data objects, providing memory management for all Data object pointers it contains. <p> It uses similar member names as std::queue<>, for consistency. <p>Definition at line <a class="el" href="dataqueue_8h-source.html#l00040">40</a> of file <a class="el" href="dataqueue_8h-source.html">dataqueue.h</a>.</p> <table border="0" cellpadding="0" cellspacing="0"> <tr><td></td></tr> <tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classBarry_1_1DataQueue.html#ea470a11cbda20dd9af1a92148ecb223">push</a> (Data *data)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Pushes data into the end of the queue. <a href="#ea470a11cbda20dd9af1a92148ecb223"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">Data * </td><td class="memItemRight" valign="bottom"><a class="el" href="classBarry_1_1DataQueue.html#d1f454f70a9b6ec667e0e22a7ddd6eca">pop</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Pops the next element off the front of the queue. <a href="#d1f454f70a9b6ec667e0e22a7ddd6eca"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">Data * </td><td class="memItemRight" valign="bottom"><a class="el" href="classBarry_1_1DataQueue.html#27d4830d37b0f7a1bee3a63b0f5a5b2b">wait_pop</a> (int timeout=-1)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Pops the next element off the front of the queue, and waits until one exists if empty. <a href="#27d4830d37b0f7a1bee3a63b0f5a5b2b"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classBarry_1_1DataQueue.html#12a7a82124799a6803b28efd89e1dd05">append_from</a> (<a class="el" href="classBarry_1_1DataQueue.html">DataQueue</a> &other)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Pops all data from other and appends it to this. <a href="#12a7a82124799a6803b28efd89e1dd05"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classBarry_1_1DataQueue.html#76cecba41e423f7d20df464cf7524e76">empty</a> () const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Returns true if the queue is empty. <a href="#76cecba41e423f7d20df464cf7524e76"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">size_t </td><td class="memItemRight" valign="bottom"><a class="el" href="classBarry_1_1DataQueue.html#da0c2fd55a8f221aadbf0b7165043e06">size</a> () const </td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Returns number of items in the queue. <a href="#da0c2fd55a8f221aadbf0b7165043e06"></a><br></td></tr> </table> <hr><h2>Member Function Documentation</h2> <a class="anchor" name="ea470a11cbda20dd9af1a92148ecb223"></a><!-- doxytag: member="Barry::DataQueue::push" ref="ea470a11cbda20dd9af1a92148ecb223" args="(Data *data)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void Barry::DataQueue::push </td> <td>(</td> <td class="paramtype">Data * </td> <td class="paramname"> <em>data</em> </td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p> Pushes data into the end of the queue. <p> The queue owns this pointer as soon as the function is called. In the case of an exception, it will be freed. Performs a thread broadcast once new data has been added. <p>Definition at line <a class="el" href="dataqueue_8cc-source.html#l00059">59</a> of file <a class="el" href="dataqueue_8cc-source.html">dataqueue.cc</a>.</p> </div> </div><p> <a class="anchor" name="d1f454f70a9b6ec667e0e22a7ddd6eca"></a><!-- doxytag: member="Barry::DataQueue::pop" ref="d1f454f70a9b6ec667e0e22a7ddd6eca" args="()" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">Data * Barry::DataQueue::pop </td> <td>(</td> <td class="paramname"> </td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p> Pops the next element off the front of the queue. <p> Returns 0 if empty. The queue no longer owns this pointer upon return. <p>Definition at line <a class="el" href="dataqueue_8cc-source.html#l00086">86</a> of file <a class="el" href="dataqueue_8cc-source.html">dataqueue.cc</a>.</p> </div> </div><p> <a class="anchor" name="27d4830d37b0f7a1bee3a63b0f5a5b2b"></a><!-- doxytag: member="Barry::DataQueue::wait_pop" ref="27d4830d37b0f7a1bee3a63b0f5a5b2b" args="(int timeout=-1)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">Data * Barry::DataQueue::wait_pop </td> <td>(</td> <td class="paramtype">int </td> <td class="paramname"> <em>timeout</em> = <code>-1</code> </td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p> Pops the next element off the front of the queue, and waits until one exists if empty. <p> If still no data on timeout, returns null. (unlock the access mutex while waiting!)<p> Timeout specified in milliseconds. Default is wait forever. <p>Definition at line <a class="el" href="dataqueue_8cc-source.html#l00108">108</a> of file <a class="el" href="dataqueue_8cc-source.html">dataqueue.cc</a>.</p> <p>References <a class="el" href="dataqueue_8cc-source.html#l00206">size()</a>, and <a class="el" href="time_8cc-source.html#l00242">Barry::ThreadTimeout()</a>.</p> <p> <div class="dynheader"> Here is the call graph for this function:</div> <div class="dynsection"> <p><center><img src="classBarry_1_1DataQueue_27d4830d37b0f7a1bee3a63b0f5a5b2b_cgraph.png" border="0" usemap="#classBarry_1_1DataQueue_27d4830d37b0f7a1bee3a63b0f5a5b2b_cgraph_map" alt=""></center> <map name="classBarry_1_1DataQueue_27d4830d37b0f7a1bee3a63b0f5a5b2b_cgraph_map"> <area shape="rect" href="classBarry_1_1DataQueue.html#da0c2fd55a8f221aadbf0b7165043e06" title="Returns number of items in the queue." alt="" coords="237,5,395,32"><area shape="rect" href="namespaceBarry.html#0e1dc80f82d25739631c39b545f812bb" title="Creates a pthread_cond_timedwait() compatible timespec struct, based on a given timeout..." alt="" coords="243,56,389,83"></map> </div> </div> </div><p> <a class="anchor" name="12a7a82124799a6803b28efd89e1dd05"></a><!-- doxytag: member="Barry::DataQueue::append_from" ref="12a7a82124799a6803b28efd89e1dd05" args="(DataQueue &other)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void Barry::DataQueue::append_from </td> <td>(</td> <td class="paramtype"><a class="el" href="classBarry_1_1DataQueue.html">DataQueue</a> & </td> <td class="paramname"> <em>other</em> </td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p> Pops all data from other and appends it to this. <p> After calling this function, other will be empty, and this will contain all its data.<p> In the case of an exception, any uncopied data will remain in other.<p> This is a locking optimization, so all copying can happen inside one lock, instead of locking for each copy. <p>Definition at line <a class="el" href="dataqueue_8cc-source.html#l00176">176</a> of file <a class="el" href="dataqueue_8cc-source.html">dataqueue.cc</a>.</p> <p>References <a class="el" href="dataqueue_8h-source.html#l00047">m_accessMutex</a>, and <a class="el" href="dataqueue_8h-source.html#l00049">m_queue</a>.</p> </div> </div><p> <a class="anchor" name="76cecba41e423f7d20df464cf7524e76"></a><!-- doxytag: member="Barry::DataQueue::empty" ref="76cecba41e423f7d20df464cf7524e76" args="() const " --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool Barry::DataQueue::empty </td> <td>(</td> <td class="paramname"> </td> <td> ) </td> <td> const</td> </tr> </table> </div> <div class="memdoc"> <p> Returns true if the queue is empty. <p> <p>Definition at line <a class="el" href="dataqueue_8cc-source.html#l00195">195</a> of file <a class="el" href="dataqueue_8cc-source.html">dataqueue.cc</a>.</p> </div> </div><p> <a class="anchor" name="da0c2fd55a8f221aadbf0b7165043e06"></a><!-- doxytag: member="Barry::DataQueue::size" ref="da0c2fd55a8f221aadbf0b7165043e06" args="() const " --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">size_t Barry::DataQueue::size </td> <td>(</td> <td class="paramname"> </td> <td> ) </td> <td> const</td> </tr> </table> </div> <div class="memdoc"> <p> Returns number of items in the queue. <p> <p>Definition at line <a class="el" href="dataqueue_8cc-source.html#l00206">206</a> of file <a class="el" href="dataqueue_8cc-source.html">dataqueue.cc</a>.</p> <p>Referenced by <a class="el" href="dataqueue_8cc-source.html#l00108">wait_pop()</a>.</p> <p> <div class="dynheader"> Here is the caller graph for this function:</div> <div class="dynsection"> <p><center><img src="classBarry_1_1DataQueue_da0c2fd55a8f221aadbf0b7165043e06_icgraph.png" border="0" usemap="#classBarry_1_1DataQueue_da0c2fd55a8f221aadbf0b7165043e06_icgraph_map" alt=""></center> <map name="classBarry_1_1DataQueue_da0c2fd55a8f221aadbf0b7165043e06_icgraph_map"> <area shape="rect" href="classBarry_1_1DataQueue.html#27d4830d37b0f7a1bee3a63b0f5a5b2b" title="Pops the next element off the front of the queue, and waits until one exists if empty..." alt="" coords="211,5,395,32"></map> </div> </div> </div><p> <hr>The documentation for this class was generated from the following files:<ul> <li><a class="el" href="dataqueue_8h-source.html">dataqueue.h</a><li><a class="el" href="dataqueue_8cc-source.html">dataqueue.cc</a></ul> </div> <hr size="1"><address style="text-align: right;"><small>Generated on Tue Mar 1 17:50:57 2011 for Barry by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address> </body> </html>