Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 29c369053a983cc5d8c880dc6e0a2237 > files > 112

libdtn-devel-2.6.0-2mdv2009.1.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>DTN Reference Implementation: BundleList.cc Source File</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.5.8 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>BundleList.cc</h1><a href="BundleList_8cc.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> *    Copyright 2004-2006 Intel Corporation</span>
<a name="l00003"></a>00003 <span class="comment"> * </span>
<a name="l00004"></a>00004 <span class="comment"> *    Licensed under the Apache License, Version 2.0 (the "License");</span>
<a name="l00005"></a>00005 <span class="comment"> *    you may not use this file except in compliance with the License.</span>
<a name="l00006"></a>00006 <span class="comment"> *    You may obtain a copy of the License at</span>
<a name="l00007"></a>00007 <span class="comment"> * </span>
<a name="l00008"></a>00008 <span class="comment"> *        http://www.apache.org/licenses/LICENSE-2.0</span>
<a name="l00009"></a>00009 <span class="comment"> * </span>
<a name="l00010"></a>00010 <span class="comment"> *    Unless required by applicable law or agreed to in writing, software</span>
<a name="l00011"></a>00011 <span class="comment"> *    distributed under the License is distributed on an "AS IS" BASIS,</span>
<a name="l00012"></a>00012 <span class="comment"> *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
<a name="l00013"></a>00013 <span class="comment"> *    See the License for the specific language governing permissions and</span>
<a name="l00014"></a>00014 <span class="comment"> *    limitations under the License.</span>
<a name="l00015"></a>00015 <span class="comment"> */</span>
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="preprocessor">#ifdef HAVE_CONFIG_H</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#  include &lt;<a class="code" href="dtn-config_8h.html">dtn-config.h</a>&gt;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#endif</span>
<a name="l00020"></a>00020 <span class="preprocessor"></span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;algorithm&gt;</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include &lt;oasys/thread/SpinLock.h&gt;</span>
<a name="l00024"></a>00024 
<a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="bundling_2Bundle_8h.html">Bundle.h</a>"</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="bundling_2BundleList_8h.html">BundleList.h</a>"</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include "<a class="code" href="BundleMappings_8h.html">BundleMappings.h</a>"</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="BundleTimestamp_8h.html">BundleTimestamp.h</a>"</span>
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 <span class="keyword">namespace </span>dtn {
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00033"></a><a class="code" href="classdtn_1_1BundleList.html#0ea669c5b8ab3dc87d18e1e8b9bf70ff">00033</a> <a class="code" href="classdtn_1_1BundleList.html#0ea669c5b8ab3dc87d18e1e8b9bf70ff" title="Constructor.">BundleList::BundleList</a>(<span class="keyword">const</span> std::string&amp; name, oasys::SpinLock* lock)
<a name="l00034"></a>00034     : <a class="code" href="classoasys_1_1Logger.html">Logger</a>(<span class="stringliteral">"BundleList"</span>, <span class="stringliteral">"/dtn/bundle/list/%s"</span>, name.c_str()),
<a name="l00035"></a>00035       name_(name), notifier_(NULL)
<a name="l00036"></a>00036 {
<a name="l00037"></a>00037     <span class="keywordflow">if</span> (lock != NULL) {
<a name="l00038"></a>00038         <a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>     = lock;
<a name="l00039"></a>00039         <a class="code" href="classdtn_1_1BundleList.html#b42f8cdc7fa16407d38975d514009861" title="bit to define lock ownership">own_lock_</a> = <span class="keyword">false</span>;
<a name="l00040"></a>00040     } <span class="keywordflow">else</span> {
<a name="l00041"></a>00041         <a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>     = <span class="keyword">new</span> oasys::SpinLock();
<a name="l00042"></a>00042         <a class="code" href="classdtn_1_1BundleList.html#b42f8cdc7fa16407d38975d514009861" title="bit to define lock ownership">own_lock_</a> = <span class="keyword">true</span>;
<a name="l00043"></a>00043     }
<a name="l00044"></a>00044 }
<a name="l00045"></a>00045 
<a name="l00046"></a>00046 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00047"></a>00047 <span class="keywordtype">void</span>
<a name="l00048"></a><a class="code" href="classdtn_1_1BundleList.html#463faba73c168a921d04e6e9d0aac756">00048</a> <a class="code" href="classdtn_1_1BundleList.html#463faba73c168a921d04e6e9d0aac756" title="Set the name (useful for classes that are unserialized).">BundleList::set_name</a>(<span class="keyword">const</span> std::string&amp; name)
<a name="l00049"></a>00049 {
<a name="l00050"></a>00050     <a class="code" href="classdtn_1_1BundleList.html#2a113958b7214c732602d956bc99a2f9" title="name of the list">name_</a> = name;
<a name="l00051"></a>00051     logpathf(<span class="stringliteral">"/dtn/bundle/list/%s"</span>, name.c_str());
<a name="l00052"></a>00052 }
<a name="l00053"></a>00053 
<a name="l00054"></a>00054 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00055"></a><a class="code" href="classdtn_1_1BundleList.html#aa529667435de9a1477d192630f75ab7">00055</a> <a class="code" href="classdtn_1_1BundleList.html#aa529667435de9a1477d192630f75ab7" title="Destructor -- clears the list.">BundleList::~BundleList</a>()
<a name="l00056"></a>00056 {
<a name="l00057"></a>00057     <a class="code" href="classdtn_1_1BundleList.html#3dfbaddbb0847b93c86e50190d173f63" title="Clear out the list.">clear</a>();
<a name="l00058"></a>00058     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1BundleList.html#b42f8cdc7fa16407d38975d514009861" title="bit to define lock ownership">own_lock_</a>) {
<a name="l00059"></a>00059         <span class="keyword">delete</span> <a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>;
<a name="l00060"></a>00060     }
<a name="l00061"></a>00061     <a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a> = NULL;
<a name="l00062"></a>00062 }
<a name="l00063"></a>00063 
<a name="l00064"></a>00064 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00065"></a>00065 <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a>
<a name="l00066"></a><a class="code" href="classdtn_1_1BundleList.html#3ff5877316c9c9c08b161b977e48b701">00066</a> <a class="code" href="classdtn_1_1BundleList.html#3ff5877316c9c9c08b161b977e48b701" title="Peek at the first bundle on the list.">BundleList::front</a>()<span class="keyword"> const</span>
<a name="l00067"></a>00067 <span class="keyword"></span>{
<a name="l00068"></a>00068     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>, <span class="stringliteral">"BundleList::front"</span>);
<a name="l00069"></a>00069     
<a name="l00070"></a>00070     <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a> ret(<span class="stringliteral">"BundleList::front() temporary"</span>);
<a name="l00071"></a>00071     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1BundleList.html#2fa0c115e2436adbe8e03795c1fa2723" title="underlying list data structure">list_</a>.empty())
<a name="l00072"></a>00072         <span class="keywordflow">return</span> ret;
<a name="l00073"></a>00073 
<a name="l00074"></a>00074     ret = <a class="code" href="classdtn_1_1BundleList.html#2fa0c115e2436adbe8e03795c1fa2723" title="underlying list data structure">list_</a>.front();
<a name="l00075"></a>00075     <span class="keywordflow">return</span> ret;
<a name="l00076"></a>00076 }
<a name="l00077"></a>00077 
<a name="l00078"></a>00078 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00079"></a>00079 <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a>
<a name="l00080"></a><a class="code" href="classdtn_1_1BundleList.html#873df4500212eae079e89fdbfe855e92">00080</a> <a class="code" href="classdtn_1_1BundleList.html#873df4500212eae079e89fdbfe855e92" title="Peek at the last bundle on the list.">BundleList::back</a>()<span class="keyword"> const</span>
<a name="l00081"></a>00081 <span class="keyword"></span>{
<a name="l00082"></a>00082     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>, <span class="stringliteral">"BundleList::back"</span>);
<a name="l00083"></a>00083 
<a name="l00084"></a>00084     <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a> ret(<span class="stringliteral">"BundleList::back() temporary"</span>);
<a name="l00085"></a>00085     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1BundleList.html#2fa0c115e2436adbe8e03795c1fa2723" title="underlying list data structure">list_</a>.empty())
<a name="l00086"></a>00086         <span class="keywordflow">return</span> ret;
<a name="l00087"></a>00087 
<a name="l00088"></a>00088     ret = <a class="code" href="classdtn_1_1BundleList.html#2fa0c115e2436adbe8e03795c1fa2723" title="underlying list data structure">list_</a>.back();
<a name="l00089"></a>00089     <span class="keywordflow">return</span> ret;
<a name="l00090"></a>00090 }
<a name="l00091"></a>00091 
<a name="l00092"></a>00092 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00093"></a>00093 <span class="keywordtype">void</span>
<a name="l00094"></a><a class="code" href="classdtn_1_1BundleList.html#9c3bcf8d558346d1224b25869251f2ef">00094</a> <a class="code" href="classdtn_1_1BundleList.html#9c3bcf8d558346d1224b25869251f2ef" title="Helper routine to add a bundle at the indicated position.">BundleList::add_bundle</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b, <span class="keyword">const</span> iterator&amp; pos)
<a name="l00095"></a>00095 {
<a name="l00096"></a>00096     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>-&gt;is_locked_by_me());
<a name="l00097"></a>00097     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(b-&gt;<a class="code" href="classdtn_1_1Bundle.html#5152156c37574a7939c6b4740fa44c66" title="Accessors.">lock</a>()-&gt;is_locked_by_me());
<a name="l00098"></a>00098     
<a name="l00099"></a>00099     <span class="keywordflow">if</span> (b-&gt;<a class="code" href="classdtn_1_1Bundle.html#13d641b5d6a6617a8c37ab28a0a6c843" title="Return true if the bundle is on the given list.">is_queued_on</a>(<span class="keyword">this</span>)) {
<a name="l00100"></a>00100         log_err(<span class="stringliteral">"ERROR in add bundle: "</span>
<a name="l00101"></a>00101                 <span class="stringliteral">"bundle id %d already on list [%s]"</span>,
<a name="l00102"></a>00102                 b-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(), <a class="code" href="classdtn_1_1BundleList.html#2a113958b7214c732602d956bc99a2f9" title="name of the list">name_</a>.c_str());
<a name="l00103"></a>00103         
<a name="l00104"></a>00104         <span class="keywordflow">return</span>;
<a name="l00105"></a>00105     }
<a name="l00106"></a>00106     
<a name="l00107"></a>00107     <a class="code" href="classdtn_1_1BundleList.html#1d52b8d6bb7d8a07e5d4f5fc4b5b61d2" title="Type for an iterator, which just wraps an stl iterator.">iterator</a> new_pos = <a class="code" href="classdtn_1_1BundleList.html#2fa0c115e2436adbe8e03795c1fa2723" title="underlying list data structure">list_</a>.insert(pos, b);
<a name="l00108"></a>00108     b-&gt;<a class="code" href="classdtn_1_1Bundle.html#00c8ac89d536bda8d596495e98064825" title="Return a pointer to the mappings.">mappings</a>()-&gt;push_back(<a class="code" href="classdtn_1_1BundleMapping.html" title="Structure stored in a list along with each bundle to keep a &amp;quot;backpointer&amp;quot;...">BundleMapping</a>(<span class="keyword">this</span>, new_pos));
<a name="l00109"></a>00109     b-&gt;<a class="code" href="classdtn_1_1Bundle.html#5c44263a2646f8e13115371b14f5359a" title="Bump up the reference count.">add_ref</a>(<span class="stringliteral">"bundle_list"</span>, <a class="code" href="classdtn_1_1BundleList.html#2a113958b7214c732602d956bc99a2f9" title="name of the list">name_</a>.c_str());
<a name="l00110"></a>00110     
<a name="l00111"></a>00111     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1BundleList.html#bf8997bf56c3876e1bc96e8b2ce895e8" title="notifier for blocking list">notifier_</a> != 0) {
<a name="l00112"></a>00112         <a class="code" href="classdtn_1_1BundleList.html#bf8997bf56c3876e1bc96e8b2ce895e8" title="notifier for blocking list">notifier_</a>-&gt;notify();
<a name="l00113"></a>00113     }
<a name="l00114"></a>00114 
<a name="l00115"></a>00115     log_debug(<span class="stringliteral">"bundle id %d add mapping [%s] to list %p"</span>,
<a name="l00116"></a>00116               b-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(), <a class="code" href="classdtn_1_1BundleList.html#2a113958b7214c732602d956bc99a2f9" title="name of the list">name_</a>.c_str(), <span class="keyword">this</span>);
<a name="l00117"></a>00117 }
<a name="l00118"></a>00118 
<a name="l00119"></a>00119 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00120"></a>00120 <span class="keywordtype">void</span>
<a name="l00121"></a><a class="code" href="classdtn_1_1BundleList.html#6a51b84005fdf2d5c89ed5231de61cf8">00121</a> <a class="code" href="classdtn_1_1BundleList.html#6a51b84005fdf2d5c89ed5231de61cf8" title="Add a new bundle to the front of the list.">BundleList::push_front</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b)
<a name="l00122"></a>00122 {
<a name="l00123"></a>00123     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>, <span class="stringliteral">"BundleList::push_front"</span>);
<a name="l00124"></a>00124     oasys::ScopeLock bl(b-&gt;<a class="code" href="classdtn_1_1Bundle.html#5152156c37574a7939c6b4740fa44c66" title="Accessors.">lock</a>(), <span class="stringliteral">"BundleList::push_front"</span>);
<a name="l00125"></a>00125     <a class="code" href="classdtn_1_1BundleList.html#9c3bcf8d558346d1224b25869251f2ef" title="Helper routine to add a bundle at the indicated position.">add_bundle</a>(b, <a class="code" href="classdtn_1_1BundleList.html#2fa0c115e2436adbe8e03795c1fa2723" title="underlying list data structure">list_</a>.begin());
<a name="l00126"></a>00126 }
<a name="l00127"></a>00127 
<a name="l00128"></a>00128 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00129"></a>00129 <span class="keywordtype">void</span>
<a name="l00130"></a><a class="code" href="classdtn_1_1BundleList.html#9f3efd0593739e89ed478fd4bbccd3e0">00130</a> <a class="code" href="classdtn_1_1BundleList.html#9f3efd0593739e89ed478fd4bbccd3e0" title="Add a new bundle to the back of the list.">BundleList::push_back</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b)
<a name="l00131"></a>00131 {
<a name="l00132"></a>00132     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>, <span class="stringliteral">"BundleList::push_back"</span>);
<a name="l00133"></a>00133     oasys::ScopeLock bl(b-&gt;<a class="code" href="classdtn_1_1Bundle.html#5152156c37574a7939c6b4740fa44c66" title="Accessors.">lock</a>(), <span class="stringliteral">"BundleList::push_back"</span>);
<a name="l00134"></a>00134     <a class="code" href="classdtn_1_1BundleList.html#9c3bcf8d558346d1224b25869251f2ef" title="Helper routine to add a bundle at the indicated position.">add_bundle</a>(b, <a class="code" href="classdtn_1_1BundleList.html#2fa0c115e2436adbe8e03795c1fa2723" title="underlying list data structure">list_</a>.end());
<a name="l00135"></a>00135 }
<a name="l00136"></a>00136         
<a name="l00137"></a>00137 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00138"></a>00138 <span class="keywordtype">void</span>
<a name="l00139"></a><a class="code" href="classdtn_1_1BundleList.html#b9b4a6a57883a5df56779c5ee633434f">00139</a> <a class="code" href="classdtn_1_1BundleList.html#b9b4a6a57883a5df56779c5ee633434f" title="Insert the given bundle sorted by the given sort method.">BundleList::insert_sorted</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b, <a class="code" href="classdtn_1_1BundleList.html#d2d5945081bd01b79d0cc2763f777f9c" title="Type codes for sorted insertion.">sort_order_t</a> sort_order)
<a name="l00140"></a>00140 {
<a name="l00141"></a>00141     <a class="code" href="classdtn_1_1BundleList.html#1d52b8d6bb7d8a07e5d4f5fc4b5b61d2" title="Type for an iterator, which just wraps an stl iterator.">iterator</a> iter;
<a name="l00142"></a>00142     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>, <span class="stringliteral">"BundleList::insert_sorted"</span>);
<a name="l00143"></a>00143     oasys::ScopeLock bl(b-&gt;<a class="code" href="classdtn_1_1Bundle.html#5152156c37574a7939c6b4740fa44c66" title="Accessors.">lock</a>(), <span class="stringliteral">"BundleList::insert_sorted"</span>);
<a name="l00144"></a>00144 
<a name="l00145"></a>00145     <span class="comment">// scan through the list until the iterator either a) reaches the</span>
<a name="l00146"></a>00146     <span class="comment">// end of the list or b) reaches the bundle that should follow the</span>
<a name="l00147"></a>00147     <span class="comment">// new insertion in the list. once the loop is done therefore, the</span>
<a name="l00148"></a>00148     <span class="comment">// insert() call will then always put the bundle in the right</span>
<a name="l00149"></a>00149     <span class="comment">// place</span>
<a name="l00150"></a>00150     <span class="comment">//</span>
<a name="l00151"></a>00151     <span class="comment">// XXX/demmer there's probably a more stl-ish way to do this but i</span>
<a name="l00152"></a>00152     <span class="comment">// don't know what it is </span>
<a name="l00153"></a>00153     
<a name="l00154"></a>00154     <span class="keywordflow">for</span> (iter = <a class="code" href="classdtn_1_1BundleList.html#2fa0c115e2436adbe8e03795c1fa2723" title="underlying list data structure">list_</a>.begin(); iter != <a class="code" href="classdtn_1_1BundleList.html#2fa0c115e2436adbe8e03795c1fa2723" title="underlying list data structure">list_</a>.end(); ++iter)
<a name="l00155"></a>00155     {
<a name="l00156"></a>00156         <span class="keywordflow">if</span> (sort_order == <a class="code" href="classdtn_1_1BundleList.html#d2d5945081bd01b79d0cc2763f777f9cb2a2c26a05eb8ccc46223f08f368e744" title="Sort by fragment offset.">SORT_FRAG_OFFSET</a>) {
<a name="l00157"></a>00157             <span class="keywordflow">if</span> ((*iter)-&gt;frag_offset() &gt; b-&gt;<a class="code" href="classdtn_1_1Bundle.html#76cf6a44f566aa22e2a98007bf233ee2" title="Accessors.">frag_offset</a>()) {
<a name="l00158"></a>00158                 <span class="keywordflow">break</span>;
<a name="l00159"></a>00159             }
<a name="l00160"></a>00160 
<a name="l00161"></a>00161         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (sort_order == <a class="code" href="classdtn_1_1BundleList.html#d2d5945081bd01b79d0cc2763f777f9c3d4fdc077df1797183a86a4fa1b5897d" title="Sort by bundle priority.">SORT_PRIORITY</a>) {
<a name="l00162"></a>00162             NOTIMPLEMENTED;
<a name="l00163"></a>00163             
<a name="l00164"></a>00164         } <span class="keywordflow">else</span> {
<a name="l00165"></a>00165             PANIC(<span class="stringliteral">"invalid value for sort order %d"</span>, sort_order);
<a name="l00166"></a>00166         }
<a name="l00167"></a>00167     }
<a name="l00168"></a>00168     
<a name="l00169"></a>00169     <a class="code" href="classdtn_1_1BundleList.html#9c3bcf8d558346d1224b25869251f2ef" title="Helper routine to add a bundle at the indicated position.">add_bundle</a>(b, iter);
<a name="l00170"></a>00170 }
<a name="l00171"></a>00171 
<a name="l00172"></a>00172 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00173"></a>00173 <span class="keywordtype">void</span>
<a name="l00174"></a><a class="code" href="classdtn_1_1BundleList.html#ed4600017614f1193d4781e1a1a34301">00174</a> <a class="code" href="classdtn_1_1BundleList.html#ed4600017614f1193d4781e1a1a34301" title="As a testing hook, insert the given bundle into a random location in the list.">BundleList::insert_random</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b)
<a name="l00175"></a>00175 {
<a name="l00176"></a>00176     <a class="code" href="classdtn_1_1BundleList.html#1d52b8d6bb7d8a07e5d4f5fc4b5b61d2" title="Type for an iterator, which just wraps an stl iterator.">iterator</a> iter;
<a name="l00177"></a>00177     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>, <span class="stringliteral">"BundleList::insert_random"</span>);
<a name="l00178"></a>00178     oasys::ScopeLock bl(b-&gt;<a class="code" href="classdtn_1_1Bundle.html#5152156c37574a7939c6b4740fa44c66" title="Accessors.">lock</a>(), <span class="stringliteral">"BundleList::insert_random"</span>);
<a name="l00179"></a>00179 
<a name="l00180"></a>00180     iter = <a class="code" href="classdtn_1_1BundleList.html#24cd371acd62f2f9725ff3f92b55badf" title="Iterator used to iterate through the list.">begin</a>();
<a name="l00181"></a>00181     <span class="keywordtype">int</span> location = 0;
<a name="l00182"></a>00182     <span class="keywordflow">if</span> (! <a class="code" href="classdtn_1_1BundleList.html#3ca5e173510164b46c8de9a95147f20d" title="Return whether or not the list is empty.">empty</a>()) {
<a name="l00183"></a>00183         location = random() % <a class="code" href="classdtn_1_1BundleList.html#3c50c6f421631a4dd72b7b77b0660bc3" title="Return the size of the list.">size</a>();
<a name="l00184"></a>00184     }
<a name="l00185"></a>00185 
<a name="l00186"></a>00186     log_info(<span class="stringliteral">"insert_random at %d/%zu"</span>, location, <a class="code" href="classdtn_1_1BundleList.html#3c50c6f421631a4dd72b7b77b0660bc3" title="Return the size of the list.">size</a>());
<a name="l00187"></a>00187     
<a name="l00188"></a>00188     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; location; ++i) {
<a name="l00189"></a>00189         ++iter;
<a name="l00190"></a>00190     }
<a name="l00191"></a>00191 
<a name="l00192"></a>00192     <a class="code" href="classdtn_1_1BundleList.html#9c3bcf8d558346d1224b25869251f2ef" title="Helper routine to add a bundle at the indicated position.">add_bundle</a>(b, iter);
<a name="l00193"></a>00193 }
<a name="l00194"></a>00194 
<a name="l00195"></a>00195 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00196"></a>00196 <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>*
<a name="l00197"></a><a class="code" href="classdtn_1_1BundleList.html#706792027fe0123f940bf2dadb842eb0">00197</a> <a class="code" href="classdtn_1_1BundleList.html#706792027fe0123f940bf2dadb842eb0" title="Helper routine to remove a bundle from the indicated position.">BundleList::del_bundle</a>(<span class="keyword">const</span> iterator&amp; pos, <span class="keywordtype">bool</span> used_notifier)
<a name="l00198"></a>00198 {
<a name="l00199"></a>00199     <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b = *pos;
<a name="l00200"></a>00200     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>-&gt;is_locked_by_me());
<a name="l00201"></a>00201     
<a name="l00202"></a>00202     <span class="comment">// lock the bundle</span>
<a name="l00203"></a>00203     oasys::ScopeLock l(b-&gt;<a class="code" href="classdtn_1_1Bundle.html#5152156c37574a7939c6b4740fa44c66" title="Accessors.">lock</a>(), <span class="stringliteral">"BundleList::del_bundle"</span>);
<a name="l00204"></a>00204 
<a name="l00205"></a>00205     <span class="comment">// remove the mapping</span>
<a name="l00206"></a>00206     log_debug(<span class="stringliteral">"bundle id %d del_bundle: deleting mapping [%s]"</span>,
<a name="l00207"></a>00207               b-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(), <a class="code" href="classdtn_1_1BundleList.html#2a113958b7214c732602d956bc99a2f9" title="name of the list">name_</a>.c_str());
<a name="l00208"></a>00208     BundleMappings::iterator mapping = b-&gt;<a class="code" href="classdtn_1_1Bundle.html#00c8ac89d536bda8d596495e98064825" title="Return a pointer to the mappings.">mappings</a>()-&gt;<a class="code" href="classdtn_1_1BundleMappings.html#8cb6a273a49dd44a5e07ca49af938a36" title="Return an iterator at the mapping to the given list, or end() if the mapping is not...">find</a>(<span class="keyword">this</span>);
<a name="l00209"></a>00209     <span class="keywordflow">if</span> (mapping == b-&gt;<a class="code" href="classdtn_1_1Bundle.html#00c8ac89d536bda8d596495e98064825" title="Return a pointer to the mappings.">mappings</a>()-&gt;end()) {
<a name="l00210"></a>00210         log_err(<span class="stringliteral">"ERROR in del bundle: "</span>
<a name="l00211"></a>00211                 <span class="stringliteral">"bundle id %d has no mapping for list [%s]"</span>,
<a name="l00212"></a>00212                 b-&gt;<a class="code" href="classdtn_1_1Bundle.html#7031e2e5e4078445bf4ad39cdcdea3b2" title="Accessors.">bundleid</a>(), <a class="code" href="classdtn_1_1BundleList.html#2a113958b7214c732602d956bc99a2f9" title="name of the list">name_</a>.c_str());
<a name="l00213"></a>00213     } <span class="keywordflow">else</span> {
<a name="l00214"></a>00214         <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(mapping-&gt;list() == <span class="keyword">this</span>);
<a name="l00215"></a>00215         <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(mapping-&gt;position() == pos);
<a name="l00216"></a>00216         b-&gt;<a class="code" href="classdtn_1_1Bundle.html#00c8ac89d536bda8d596495e98064825" title="Return a pointer to the mappings.">mappings</a>()-&gt;erase(mapping);
<a name="l00217"></a>00217     }
<a name="l00218"></a>00218     
<a name="l00219"></a>00219     <span class="comment">// remove the bundle from the list</span>
<a name="l00220"></a>00220     <a class="code" href="classdtn_1_1BundleList.html#2fa0c115e2436adbe8e03795c1fa2723" title="underlying list data structure">list_</a>.erase(pos);
<a name="l00221"></a>00221     
<a name="l00222"></a>00222     <span class="comment">// drain one element from the semaphore</span>
<a name="l00223"></a>00223     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1BundleList.html#bf8997bf56c3876e1bc96e8b2ce895e8" title="notifier for blocking list">notifier_</a> &amp;&amp; !used_notifier) {
<a name="l00224"></a>00224         <a class="code" href="classdtn_1_1BundleList.html#bf8997bf56c3876e1bc96e8b2ce895e8" title="notifier for blocking list">notifier_</a>-&gt;drain_pipe(1);
<a name="l00225"></a>00225     }
<a name="l00226"></a>00226 
<a name="l00227"></a>00227     <span class="comment">// note that we explicitly do _not_ decrement the reference count</span>
<a name="l00228"></a>00228     <span class="comment">// since the reference is passed to the calling function</span>
<a name="l00229"></a>00229     
<a name="l00230"></a>00230     <span class="keywordflow">return</span> b;
<a name="l00231"></a>00231 }
<a name="l00232"></a>00232 
<a name="l00233"></a>00233 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00234"></a>00234 <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a>
<a name="l00235"></a><a class="code" href="classdtn_1_1BundleList.html#265a9efd0831be3094f815eed22aec42">00235</a> <a class="code" href="classdtn_1_1BundleList.html#265a9efd0831be3094f815eed22aec42" title="Remove (and return) a reference to the first bundle on the list.">BundleList::pop_front</a>(<span class="keywordtype">bool</span> used_notifier)
<a name="l00236"></a>00236 {
<a name="l00237"></a>00237     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>, <span class="stringliteral">"pop_front"</span>);
<a name="l00238"></a>00238 
<a name="l00239"></a>00239     <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a> ret(<span class="stringliteral">"BundleList::pop_front() temporary"</span>);
<a name="l00240"></a>00240 
<a name="l00241"></a>00241     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1BundleList.html#2fa0c115e2436adbe8e03795c1fa2723" title="underlying list data structure">list_</a>.empty()) {
<a name="l00242"></a>00242         <span class="keywordflow">return</span> ret;
<a name="l00243"></a>00243     }
<a name="l00244"></a>00244     
<a name="l00245"></a>00245     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(!<a class="code" href="classdtn_1_1BundleList.html#3ca5e173510164b46c8de9a95147f20d" title="Return whether or not the list is empty.">empty</a>());
<a name="l00246"></a>00246 
<a name="l00247"></a>00247     <span class="comment">// Assign the bundle to a temporary reference, then remove the</span>
<a name="l00248"></a>00248     <span class="comment">// list reference on the bundle and return the temporary</span>
<a name="l00249"></a>00249     ret = <a class="code" href="classdtn_1_1BundleList.html#706792027fe0123f940bf2dadb842eb0" title="Helper routine to remove a bundle from the indicated position.">del_bundle</a>(<a class="code" href="classdtn_1_1BundleList.html#2fa0c115e2436adbe8e03795c1fa2723" title="underlying list data structure">list_</a>.begin(), used_notifier);
<a name="l00250"></a>00250     ret.object()-&gt;<a class="code" href="classdtn_1_1Bundle.html#386b3d36bfdbe4528b4fcaaf1078063c" title="Decrement the reference count.">del_ref</a>(<span class="stringliteral">"bundle_list"</span>, <a class="code" href="classdtn_1_1BundleList.html#2a113958b7214c732602d956bc99a2f9" title="name of the list">name_</a>.c_str()); 
<a name="l00251"></a>00251     <span class="keywordflow">return</span> ret;
<a name="l00252"></a>00252 }
<a name="l00253"></a>00253 
<a name="l00254"></a>00254 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00255"></a>00255 <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a>
<a name="l00256"></a><a class="code" href="classdtn_1_1BundleList.html#3429d8c70e63925609713c6d6fbd51fe">00256</a> <a class="code" href="classdtn_1_1BundleList.html#3429d8c70e63925609713c6d6fbd51fe" title="Remove (and return) the last bundle on the list.">BundleList::pop_back</a>(<span class="keywordtype">bool</span> used_notifier)
<a name="l00257"></a>00257 {
<a name="l00258"></a>00258     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>, <span class="stringliteral">"BundleList::pop_back"</span>);
<a name="l00259"></a>00259 
<a name="l00260"></a>00260     <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a> ret(<span class="stringliteral">"BundleList::pop_back() temporary"</span>);
<a name="l00261"></a>00261 
<a name="l00262"></a>00262     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1BundleList.html#2fa0c115e2436adbe8e03795c1fa2723" title="underlying list data structure">list_</a>.empty()) {
<a name="l00263"></a>00263         <span class="keywordflow">return</span> ret;
<a name="l00264"></a>00264     }
<a name="l00265"></a>00265 
<a name="l00266"></a>00266     <span class="comment">// Assign the bundle to a temporary reference, then remove the</span>
<a name="l00267"></a>00267     <span class="comment">// list reference on the bundle and return the temporary</span>
<a name="l00268"></a>00268     ret = <a class="code" href="classdtn_1_1BundleList.html#706792027fe0123f940bf2dadb842eb0" title="Helper routine to remove a bundle from the indicated position.">del_bundle</a>(--<a class="code" href="classdtn_1_1BundleList.html#2fa0c115e2436adbe8e03795c1fa2723" title="underlying list data structure">list_</a>.end(), used_notifier);
<a name="l00269"></a>00269     ret-&gt;<a class="code" href="classdtn_1_1Bundle.html#386b3d36bfdbe4528b4fcaaf1078063c" title="Decrement the reference count.">del_ref</a>(<span class="stringliteral">"bundle_list"</span>, <a class="code" href="classdtn_1_1BundleList.html#2a113958b7214c732602d956bc99a2f9" title="name of the list">name_</a>.c_str()); 
<a name="l00270"></a>00270     <span class="keywordflow">return</span> ret;
<a name="l00271"></a>00271 }
<a name="l00272"></a>00272 
<a name="l00273"></a>00273 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00274"></a>00274 <span class="keywordtype">bool</span>
<a name="l00275"></a><a class="code" href="classdtn_1_1BundleList.html#b0171458e14d67307b74f98447062d68">00275</a> <a class="code" href="classdtn_1_1BundleList.html#b0171458e14d67307b74f98447062d68" title="Remove the given bundle from the list.">BundleList::erase</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle, <span class="keywordtype">bool</span> used_notifier)
<a name="l00276"></a>00276 {
<a name="l00277"></a>00277     <span class="keywordflow">if</span> (bundle == NULL) {
<a name="l00278"></a>00278         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00279"></a>00279     }
<a name="l00280"></a>00280 
<a name="l00281"></a>00281     <span class="comment">// The bundle list lock must always be taken before the</span>
<a name="l00282"></a>00282     <span class="comment">// to-be-erased bundle lock.</span>
<a name="l00283"></a>00283     ASSERTF(!bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#5152156c37574a7939c6b4740fa44c66" title="Accessors.">lock</a>()-&gt;is_locked_by_me(),
<a name="l00284"></a>00284             <span class="stringliteral">"bundle cannot be locked before calling erase "</span>
<a name="l00285"></a>00285             <span class="stringliteral">"due to potential deadlock"</span>);
<a name="l00286"></a>00286     
<a name="l00287"></a>00287     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>, <span class="stringliteral">"BundleList::erase"</span>);
<a name="l00288"></a>00288 
<a name="l00289"></a>00289     <span class="comment">// Now we need to take the bundle lock in order to search through</span>
<a name="l00290"></a>00290     <span class="comment">// its mappings</span>
<a name="l00291"></a>00291     oasys::ScopeLock bl(bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#5152156c37574a7939c6b4740fa44c66" title="Accessors.">lock</a>(), <span class="stringliteral">"BundleList::erase"</span>);
<a name="l00292"></a>00292     
<a name="l00293"></a>00293     BundleMappings::iterator mapping = bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#00c8ac89d536bda8d596495e98064825" title="Return a pointer to the mappings.">mappings</a>()-&gt;<a class="code" href="classdtn_1_1BundleMappings.html#8cb6a273a49dd44a5e07ca49af938a36" title="Return an iterator at the mapping to the given list, or end() if the mapping is not...">find</a>(<span class="keyword">this</span>);
<a name="l00294"></a>00294     <span class="keywordflow">if</span> (mapping == bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#00c8ac89d536bda8d596495e98064825" title="Return a pointer to the mappings.">mappings</a>()-&gt;end()) {
<a name="l00295"></a>00295         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00296"></a>00296     }
<a name="l00297"></a>00297 
<a name="l00298"></a>00298     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(mapping-&gt;list() == <span class="keyword">this</span>);
<a name="l00299"></a>00299     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(*mapping-&gt;position() == bundle);
<a name="l00300"></a>00300 
<a name="l00301"></a>00301     <span class="comment">// Make a local copy of the position since del_bundle destroys the</span>
<a name="l00302"></a>00302     <span class="comment">// mapping object but still needs the position.</span>
<a name="l00303"></a>00303     <a class="code" href="classdtn_1_1BundleList.html#1d52b8d6bb7d8a07e5d4f5fc4b5b61d2" title="Type for an iterator, which just wraps an stl iterator.">iterator</a> pos = mapping-&gt;position();
<a name="l00304"></a>00304     <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b = <a class="code" href="classdtn_1_1BundleList.html#706792027fe0123f940bf2dadb842eb0" title="Helper routine to remove a bundle from the indicated position.">del_bundle</a>(pos, used_notifier);
<a name="l00305"></a>00305     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(b == bundle);
<a name="l00306"></a>00306     
<a name="l00307"></a>00307     bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#386b3d36bfdbe4528b4fcaaf1078063c" title="Decrement the reference count.">del_ref</a>(<span class="stringliteral">"bundle_list"</span>, <a class="code" href="classdtn_1_1BundleList.html#2a113958b7214c732602d956bc99a2f9" title="name of the list">name_</a>.c_str());
<a name="l00308"></a>00308     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00309"></a>00309 }
<a name="l00310"></a>00310 
<a name="l00311"></a>00311 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00312"></a>00312 <span class="keywordtype">void</span>
<a name="l00313"></a><a class="code" href="classdtn_1_1BundleList.html#8030a392379011551fb796f08a213934">00313</a> <a class="code" href="classdtn_1_1BundleList.html#b0171458e14d67307b74f98447062d68" title="Remove the given bundle from the list.">BundleList::erase</a>(iterator&amp; iter, <span class="keywordtype">bool</span> used_notifier)
<a name="l00314"></a>00314 {
<a name="l00315"></a>00315     <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle = *iter;
<a name="l00316"></a>00316     ASSERTF(!bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#5152156c37574a7939c6b4740fa44c66" title="Accessors.">lock</a>()-&gt;is_locked_by_me(),
<a name="l00317"></a>00317             <span class="stringliteral">"bundle cannot be locked in erase due to potential deadlock"</span>);
<a name="l00318"></a>00318     
<a name="l00319"></a>00319     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>, <span class="stringliteral">"BundleList::erase"</span>);
<a name="l00320"></a>00320     
<a name="l00321"></a>00321     <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* b = <a class="code" href="classdtn_1_1BundleList.html#706792027fe0123f940bf2dadb842eb0" title="Helper routine to remove a bundle from the indicated position.">del_bundle</a>(iter, used_notifier);
<a name="l00322"></a>00322     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(b == bundle);
<a name="l00323"></a>00323     
<a name="l00324"></a>00324     bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#386b3d36bfdbe4528b4fcaaf1078063c" title="Decrement the reference count.">del_ref</a>(<span class="stringliteral">"bundle_list"</span>, <a class="code" href="classdtn_1_1BundleList.html#2a113958b7214c732602d956bc99a2f9" title="name of the list">name_</a>.c_str());
<a name="l00325"></a>00325 }
<a name="l00326"></a>00326 
<a name="l00327"></a>00327 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00328"></a>00328 <span class="keywordtype">bool</span>
<a name="l00329"></a><a class="code" href="classdtn_1_1BundleList.html#6398bb64194aa88b63e7d0e89e141883">00329</a> <a class="code" href="classdtn_1_1BundleList.html#6398bb64194aa88b63e7d0e89e141883" title="Search the list for the given bundle.">BundleList::contains</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle)<span class="keyword"> const</span>
<a name="l00330"></a>00330 <span class="keyword"></span>{
<a name="l00331"></a>00331     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>, <span class="stringliteral">"BundleList::contains"</span>);
<a name="l00332"></a>00332     
<a name="l00333"></a>00333     <span class="keywordflow">if</span> (bundle == NULL) {
<a name="l00334"></a>00334         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00335"></a>00335     }
<a name="l00336"></a>00336     
<a name="l00337"></a>00337     <span class="keywordtype">bool</span> ret = bundle-&gt;<a class="code" href="classdtn_1_1Bundle.html#13d641b5d6a6617a8c37ab28a0a6c843" title="Return true if the bundle is on the given list.">is_queued_on</a>(<span class="keyword">this</span>);
<a name="l00338"></a>00338 
<a name="l00339"></a>00339 <span class="preprocessor">#define DEBUG_MAPPINGS</span>
<a name="l00340"></a>00340 <span class="preprocessor"></span><span class="preprocessor">#ifdef DEBUG_MAPPINGS</span>
<a name="l00341"></a>00341 <span class="preprocessor"></span>    <span class="keywordtype">bool</span> ret2 = (<a class="code" href="classdtn_1_1BundleList.html#2958520b5b132bb3ed3f3e26c1eb295e" title="Search the list for a bundle with the given id.">std::find</a>(<a class="code" href="classdtn_1_1BundleList.html#24cd371acd62f2f9725ff3f92b55badf" title="Iterator used to iterate through the list.">begin</a>(), <a class="code" href="classdtn_1_1BundleList.html#19f95941fe436d25ba49ae0b2d8bf2c1" title="Iterator used to mark the end of the list.">end</a>(), bundle) != <a class="code" href="classdtn_1_1BundleList.html#19f95941fe436d25ba49ae0b2d8bf2c1" title="Iterator used to mark the end of the list.">end</a>());
<a name="l00342"></a>00342     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(ret == ret2);
<a name="l00343"></a>00343 <span class="preprocessor">#endif</span>
<a name="l00344"></a>00344 <span class="preprocessor"></span>
<a name="l00345"></a>00345     <span class="keywordflow">return</span> ret;
<a name="l00346"></a>00346 }
<a name="l00347"></a>00347 
<a name="l00348"></a>00348 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00349"></a>00349 <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a>
<a name="l00350"></a><a class="code" href="classdtn_1_1BundleList.html#2958520b5b132bb3ed3f3e26c1eb295e">00350</a> <a class="code" href="classdtn_1_1BundleList.html#2958520b5b132bb3ed3f3e26c1eb295e" title="Search the list for a bundle with the given id.">BundleList::find</a>(u_int32_t <a class="code" href="dtncat_8c.html#0d43174f8d3844aa5df38af2712ccb00">bundle_id</a>)<span class="keyword"> const</span>
<a name="l00351"></a>00351 <span class="keyword"></span>{
<a name="l00352"></a>00352     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>, <span class="stringliteral">"BundleList::find"</span>);
<a name="l00353"></a>00353     <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a> ret(<span class="stringliteral">"BundleList::find() temporary"</span>);
<a name="l00354"></a>00354     <span class="keywordflow">for</span> (<a class="code" href="classdtn_1_1BundleList.html#1d52b8d6bb7d8a07e5d4f5fc4b5b61d2" title="Type for an iterator, which just wraps an stl iterator.">iterator</a> iter = <a class="code" href="classdtn_1_1BundleList.html#24cd371acd62f2f9725ff3f92b55badf" title="Iterator used to iterate through the list.">begin</a>(); iter != <a class="code" href="classdtn_1_1BundleList.html#19f95941fe436d25ba49ae0b2d8bf2c1" title="Iterator used to mark the end of the list.">end</a>(); ++iter) {
<a name="l00355"></a>00355         <span class="keywordflow">if</span> ((*iter)-&gt;bundleid() == bundle_id) {
<a name="l00356"></a>00356             ret = *iter;
<a name="l00357"></a>00357             <span class="keywordflow">return</span> ret;
<a name="l00358"></a>00358         }
<a name="l00359"></a>00359     }
<a name="l00360"></a>00360 
<a name="l00361"></a>00361     <span class="keywordflow">return</span> ret;
<a name="l00362"></a>00362 }
<a name="l00363"></a>00363 
<a name="l00364"></a>00364 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00365"></a>00365 <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a>
<a name="l00366"></a><a class="code" href="classdtn_1_1BundleList.html#85166bbc1da207c0356ca79d8087f76c">00366</a> <a class="code" href="classdtn_1_1BundleList.html#2958520b5b132bb3ed3f3e26c1eb295e" title="Search the list for a bundle with the given id.">BundleList::find</a>(<span class="keyword">const</span> <a class="code" href="classdtn_1_1EndpointID.html">EndpointID</a>&amp; source_eid,
<a name="l00367"></a>00367                  <span class="keyword">const</span> <a class="code" href="structdtn_1_1BundleTimestamp.html" title="Simple struct definition for bundle creation timestamps.">BundleTimestamp</a>&amp; creation_ts)<span class="keyword"> const</span>
<a name="l00368"></a>00368 <span class="keyword"></span>{
<a name="l00369"></a>00369     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>, <span class="stringliteral">"BundleList::find"</span>);
<a name="l00370"></a>00370     <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a> ret(<span class="stringliteral">"BundleList::find() temporary"</span>);
<a name="l00371"></a>00371     
<a name="l00372"></a>00372     <span class="keywordflow">for</span> (<a class="code" href="classdtn_1_1BundleList.html#1d52b8d6bb7d8a07e5d4f5fc4b5b61d2" title="Type for an iterator, which just wraps an stl iterator.">iterator</a> iter = <a class="code" href="classdtn_1_1BundleList.html#24cd371acd62f2f9725ff3f92b55badf" title="Iterator used to iterate through the list.">begin</a>(); iter != <a class="code" href="classdtn_1_1BundleList.html#19f95941fe436d25ba49ae0b2d8bf2c1" title="Iterator used to mark the end of the list.">end</a>(); ++iter) {
<a name="l00373"></a>00373         <span class="keywordflow">if</span> ((*iter)-&gt;creation_ts().seconds_ == creation_ts.<a class="code" href="structdtn_1_1BundleTimestamp.html#02c8a347150620243240655bdcd2f42d" title="Seconds since 1/1/2000.">seconds_</a> &amp;&amp;
<a name="l00374"></a>00374             (*iter)-&gt;creation_ts().seqno_ == creation_ts.<a class="code" href="structdtn_1_1BundleTimestamp.html#ebc8cea66862d7f6056da450db410347" title="Sub-second sequence number.">seqno_</a> &amp;&amp;
<a name="l00375"></a>00375             (*iter)-&gt;source().equals(source_eid))
<a name="l00376"></a>00376         {
<a name="l00377"></a>00377             ret = *iter;
<a name="l00378"></a>00378             <span class="keywordflow">return</span> ret;
<a name="l00379"></a>00379         }
<a name="l00380"></a>00380     }
<a name="l00381"></a>00381 
<a name="l00382"></a>00382     <span class="keywordflow">return</span> ret;
<a name="l00383"></a>00383 }
<a name="l00384"></a>00384 
<a name="l00385"></a>00385 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00386"></a>00386 <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a>
<a name="l00387"></a><a class="code" href="classdtn_1_1BundleList.html#989b3b33ea16a03ed9bf8a4302bebdb0">00387</a> <a class="code" href="classdtn_1_1BundleList.html#2958520b5b132bb3ed3f3e26c1eb295e" title="Search the list for a bundle with the given id.">BundleList::find</a>(<a class="code" href="classdtn_1_1GbofId.html" title="Class definition for a GBOF ID (Global Bundle Or Fragment ID).">GbofId</a>&amp; gbof_id)<span class="keyword"> const</span>
<a name="l00388"></a>00388 <span class="keyword"></span>{
<a name="l00389"></a>00389     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>, <span class="stringliteral">"BundleList::find"</span>);
<a name="l00390"></a>00390     <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a> ret(<span class="stringliteral">"BundleList::find() temporary"</span>);
<a name="l00391"></a>00391     
<a name="l00392"></a>00392     <span class="keywordflow">for</span> (<a class="code" href="classdtn_1_1BundleList.html#1d52b8d6bb7d8a07e5d4f5fc4b5b61d2" title="Type for an iterator, which just wraps an stl iterator.">iterator</a> iter = <a class="code" href="classdtn_1_1BundleList.html#24cd371acd62f2f9725ff3f92b55badf" title="Iterator used to iterate through the list.">begin</a>(); iter != <a class="code" href="classdtn_1_1BundleList.html#19f95941fe436d25ba49ae0b2d8bf2c1" title="Iterator used to mark the end of the list.">end</a>(); ++iter) {
<a name="l00393"></a>00393         <span class="keywordflow">if</span> (gbof_id.<a class="code" href="classdtn_1_1GbofId.html#36f42d9aec096d198c352edc89836fba" title="Compares if GBOF IDs are the same.">equals</a>((*iter)-&gt;source(),
<a name="l00394"></a>00394                            (*iter)-&gt;creation_ts(),
<a name="l00395"></a>00395                            (*iter)-&gt;is_fragment(),
<a name="l00396"></a>00396                            (*iter)-&gt;payload().length(),
<a name="l00397"></a>00397                            (*iter)-&gt;frag_offset()))
<a name="l00398"></a>00398             {
<a name="l00399"></a>00399             ret = *iter;
<a name="l00400"></a>00400             <span class="keywordflow">return</span> ret;
<a name="l00401"></a>00401         }
<a name="l00402"></a>00402     }
<a name="l00403"></a>00403 
<a name="l00404"></a>00404     <span class="keywordflow">return</span> ret;
<a name="l00405"></a>00405 }
<a name="l00406"></a>00406 
<a name="l00407"></a>00407 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00408"></a>00408 <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a>
<a name="l00409"></a><a class="code" href="classdtn_1_1BundleList.html#f6723c87d4da6a2ca6eb63f06746ea1c">00409</a> <a class="code" href="classdtn_1_1BundleList.html#2958520b5b132bb3ed3f3e26c1eb295e" title="Search the list for a bundle with the given id.">BundleList::find</a>(<span class="keyword">const</span> <a class="code" href="classdtn_1_1GbofId.html" title="Class definition for a GBOF ID (Global Bundle Or Fragment ID).">GbofId</a>&amp; gbof_id, <span class="keyword">const</span> <a class="code" href="structdtn_1_1BundleTimestamp.html" title="Simple struct definition for bundle creation timestamps.">BundleTimestamp</a>&amp; extended_id)<span class="keyword"> const</span>
<a name="l00410"></a>00410 <span class="keyword"></span>{
<a name="l00411"></a>00411     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>, <span class="stringliteral">"BundleList::find"</span>);
<a name="l00412"></a>00412     <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a> ret(<span class="stringliteral">"BundleList::find() temporary"</span>);
<a name="l00413"></a>00413     
<a name="l00414"></a>00414     <span class="keywordflow">for</span> (<a class="code" href="classdtn_1_1BundleList.html#1d52b8d6bb7d8a07e5d4f5fc4b5b61d2" title="Type for an iterator, which just wraps an stl iterator.">iterator</a> iter = <a class="code" href="classdtn_1_1BundleList.html#24cd371acd62f2f9725ff3f92b55badf" title="Iterator used to iterate through the list.">begin</a>(); iter != <a class="code" href="classdtn_1_1BundleList.html#19f95941fe436d25ba49ae0b2d8bf2c1" title="Iterator used to mark the end of the list.">end</a>(); ++iter) {
<a name="l00415"></a>00415         <span class="keywordflow">if</span> (extended_id == (*iter)-&gt;extended_id() &amp;&amp;
<a name="l00416"></a>00416             gbof_id.<a class="code" href="classdtn_1_1GbofId.html#36f42d9aec096d198c352edc89836fba" title="Compares if GBOF IDs are the same.">equals</a>((*iter)-&gt;source(),
<a name="l00417"></a>00417                            (*iter)-&gt;creation_ts(),
<a name="l00418"></a>00418                            (*iter)-&gt;is_fragment(),
<a name="l00419"></a>00419                            (*iter)-&gt;payload().length(),
<a name="l00420"></a>00420                            (*iter)-&gt;frag_offset()))
<a name="l00421"></a>00421         {
<a name="l00422"></a>00422             ret = *iter;
<a name="l00423"></a>00423             <span class="keywordflow">return</span> ret;
<a name="l00424"></a>00424         }
<a name="l00425"></a>00425     }
<a name="l00426"></a>00426 
<a name="l00427"></a>00427     <span class="keywordflow">return</span> ret;
<a name="l00428"></a>00428 }
<a name="l00429"></a>00429 
<a name="l00430"></a>00430 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00431"></a>00431 <span class="keywordtype">void</span>
<a name="l00432"></a><a class="code" href="classdtn_1_1BundleList.html#af966a2b08526b4fee25b8890f7e5dcd">00432</a> <a class="code" href="classdtn_1_1BundleList.html#af966a2b08526b4fee25b8890f7e5dcd" title="Move all bundles from this list to another.">BundleList::move_contents</a>(<a class="code" href="classdtn_1_1BundleList.html" title="List structure for handling bundles.">BundleList</a>* other)
<a name="l00433"></a>00433 {
<a name="l00434"></a>00434     oasys::ScopeLock l1(<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>, <span class="stringliteral">"BundleList::move_contents"</span>);
<a name="l00435"></a>00435     oasys::ScopeLock l2(other-&gt;<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>, <span class="stringliteral">"BundleList::move_contents"</span>);
<a name="l00436"></a>00436 
<a name="l00437"></a>00437     <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a> b(<span class="stringliteral">"BundleList::move_contents temporary"</span>);
<a name="l00438"></a>00438     <span class="keywordflow">while</span> (!<a class="code" href="classdtn_1_1BundleList.html#2fa0c115e2436adbe8e03795c1fa2723" title="underlying list data structure">list_</a>.empty()) {
<a name="l00439"></a>00439         b = <a class="code" href="classdtn_1_1BundleList.html#265a9efd0831be3094f815eed22aec42" title="Remove (and return) a reference to the first bundle on the list.">pop_front</a>();
<a name="l00440"></a>00440         other-&gt;<a class="code" href="classdtn_1_1BundleList.html#9f3efd0593739e89ed478fd4bbccd3e0" title="Add a new bundle to the back of the list.">push_back</a>(b.object());
<a name="l00441"></a>00441     }
<a name="l00442"></a>00442 }
<a name="l00443"></a>00443 
<a name="l00444"></a>00444 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00445"></a>00445 <span class="keywordtype">void</span>
<a name="l00446"></a><a class="code" href="classdtn_1_1BundleList.html#3dfbaddbb0847b93c86e50190d173f63">00446</a> <a class="code" href="classdtn_1_1BundleList.html#3dfbaddbb0847b93c86e50190d173f63" title="Clear out the list.">BundleList::clear</a>()
<a name="l00447"></a>00447 {
<a name="l00448"></a>00448     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>, <span class="stringliteral">"BundleList::clear"</span>);
<a name="l00449"></a>00449     
<a name="l00450"></a>00450     <span class="keywordflow">while</span> (!<a class="code" href="classdtn_1_1BundleList.html#2fa0c115e2436adbe8e03795c1fa2723" title="underlying list data structure">list_</a>.empty()) {
<a name="l00451"></a>00451         <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a> b(<span class="stringliteral">"BundleList::clear temporary"</span>);
<a name="l00452"></a>00452         b = <a class="code" href="classdtn_1_1BundleList.html#265a9efd0831be3094f815eed22aec42" title="Remove (and return) a reference to the first bundle on the list.">pop_front</a>();
<a name="l00453"></a>00453     }
<a name="l00454"></a>00454 }
<a name="l00455"></a>00455 
<a name="l00456"></a>00456 
<a name="l00457"></a>00457 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00458"></a>00458 <span class="keywordtype">size_t</span>
<a name="l00459"></a><a class="code" href="classdtn_1_1BundleList.html#3c50c6f421631a4dd72b7b77b0660bc3">00459</a> <a class="code" href="classdtn_1_1BundleList.html#3c50c6f421631a4dd72b7b77b0660bc3" title="Return the size of the list.">BundleList::size</a>()<span class="keyword"> const</span>
<a name="l00460"></a>00460 <span class="keyword"></span>{
<a name="l00461"></a>00461     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>, <span class="stringliteral">"BundleList::size"</span>);
<a name="l00462"></a>00462     <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1BundleList.html#2fa0c115e2436adbe8e03795c1fa2723" title="underlying list data structure">list_</a>.size();
<a name="l00463"></a>00463 }
<a name="l00464"></a>00464 
<a name="l00465"></a>00465 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00466"></a>00466 <span class="keywordtype">bool</span>
<a name="l00467"></a><a class="code" href="classdtn_1_1BundleList.html#3ca5e173510164b46c8de9a95147f20d">00467</a> <a class="code" href="classdtn_1_1BundleList.html#3ca5e173510164b46c8de9a95147f20d" title="Return whether or not the list is empty.">BundleList::empty</a>()<span class="keyword"> const</span>
<a name="l00468"></a>00468 <span class="keyword"></span>{
<a name="l00469"></a>00469     oasys::ScopeLock l(<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>, <span class="stringliteral">"BundleList::empty"</span>);
<a name="l00470"></a>00470     <span class="keywordflow">return</span> <a class="code" href="classdtn_1_1BundleList.html#2fa0c115e2436adbe8e03795c1fa2723" title="underlying list data structure">list_</a>.empty();
<a name="l00471"></a>00471 }
<a name="l00472"></a>00472 
<a name="l00473"></a>00473 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00474"></a>00474 <a class="code" href="classdtn_1_1BundleList.html#1d52b8d6bb7d8a07e5d4f5fc4b5b61d2" title="Type for an iterator, which just wraps an stl iterator.">BundleList::iterator</a>
<a name="l00475"></a><a class="code" href="classdtn_1_1BundleList.html#24cd371acd62f2f9725ff3f92b55badf">00475</a> <a class="code" href="classdtn_1_1BundleList.html#24cd371acd62f2f9725ff3f92b55badf" title="Iterator used to iterate through the list.">BundleList::begin</a>()<span class="keyword"> const</span>
<a name="l00476"></a>00476 <span class="keyword"></span>{
<a name="l00477"></a>00477     <span class="keywordflow">if</span> (!<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>-&gt;is_locked_by_me())
<a name="l00478"></a>00478         PANIC(<span class="stringliteral">"Must lock BundleList before using iterator"</span>);
<a name="l00479"></a>00479 
<a name="l00480"></a>00480     <span class="comment">// since all list accesses are protected via the BundleList class</span>
<a name="l00481"></a>00481     <span class="comment">// const/non-const nature, there's no reason to use the stl</span>
<a name="l00482"></a>00482     <span class="comment">// const_iterator type, so we need to cast away constness</span>
<a name="l00483"></a>00483     <span class="keywordflow">return</span> <span class="keyword">const_cast&lt;</span><a class="code" href="classdtn_1_1BundleList.html" title="List structure for handling bundles.">BundleList</a>*<span class="keyword">&gt;</span>(<span class="keyword">this</span>)-&gt;<a class="code" href="classdtn_1_1BundleList.html#2fa0c115e2436adbe8e03795c1fa2723" title="underlying list data structure">list_</a>.begin();
<a name="l00484"></a>00484 }
<a name="l00485"></a>00485 
<a name="l00486"></a>00486 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00487"></a>00487 <a class="code" href="classdtn_1_1BundleList.html#1d52b8d6bb7d8a07e5d4f5fc4b5b61d2" title="Type for an iterator, which just wraps an stl iterator.">BundleList::iterator</a>
<a name="l00488"></a><a class="code" href="classdtn_1_1BundleList.html#19f95941fe436d25ba49ae0b2d8bf2c1">00488</a> <a class="code" href="classdtn_1_1BundleList.html#19f95941fe436d25ba49ae0b2d8bf2c1" title="Iterator used to mark the end of the list.">BundleList::end</a>()<span class="keyword"> const</span>
<a name="l00489"></a>00489 <span class="keyword"></span>{
<a name="l00490"></a>00490     <span class="keywordflow">if</span> (!<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>-&gt;is_locked_by_me())
<a name="l00491"></a>00491         PANIC(<span class="stringliteral">"Must lock BundleList before using iterator"</span>);
<a name="l00492"></a>00492 
<a name="l00493"></a>00493     <span class="comment">// see above</span>
<a name="l00494"></a>00494     <span class="keywordflow">return</span> <span class="keyword">const_cast&lt;</span><a class="code" href="classdtn_1_1BundleList.html" title="List structure for handling bundles.">BundleList</a>*<span class="keyword">&gt;</span>(<span class="keyword">this</span>)-&gt;<a class="code" href="classdtn_1_1BundleList.html#2fa0c115e2436adbe8e03795c1fa2723" title="underlying list data structure">list_</a>.end();
<a name="l00495"></a>00495 }
<a name="l00496"></a>00496 
<a name="l00497"></a>00497 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00498"></a><a class="code" href="classdtn_1_1BlockingBundleList.html#c14d6077337e48362b390f2ea3f2e095">00498</a> <a class="code" href="classdtn_1_1BlockingBundleList.html#c14d6077337e48362b390f2ea3f2e095">BlockingBundleList::BlockingBundleList</a>(<span class="keyword">const</span> std::string&amp; name)
<a name="l00499"></a>00499     : <a class="code" href="classdtn_1_1BundleList.html" title="List structure for handling bundles.">BundleList</a>(name)
<a name="l00500"></a>00500 {
<a name="l00501"></a>00501     <a class="code" href="classdtn_1_1BundleList.html#bf8997bf56c3876e1bc96e8b2ce895e8" title="notifier for blocking list">notifier_</a> = <span class="keyword">new</span> oasys::Notifier(logpath_);
<a name="l00502"></a>00502 }
<a name="l00503"></a>00503 
<a name="l00504"></a>00504 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00505"></a><a class="code" href="classdtn_1_1BlockingBundleList.html#ca722942b1031dae4a0c0012938297aa">00505</a> <a class="code" href="classdtn_1_1BlockingBundleList.html#ca722942b1031dae4a0c0012938297aa">BlockingBundleList::~BlockingBundleList</a>()
<a name="l00506"></a>00506 {
<a name="l00507"></a>00507     <span class="keyword">delete</span> <a class="code" href="classdtn_1_1BundleList.html#bf8997bf56c3876e1bc96e8b2ce895e8" title="notifier for blocking list">notifier_</a>;
<a name="l00508"></a>00508     <a class="code" href="classdtn_1_1BundleList.html#bf8997bf56c3876e1bc96e8b2ce895e8" title="notifier for blocking list">notifier_</a> = NULL;
<a name="l00509"></a>00509 }
<a name="l00510"></a>00510 
<a name="l00511"></a>00511 <span class="comment">//----------------------------------------------------------------------</span>
<a name="l00512"></a>00512 <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a>
<a name="l00513"></a><a class="code" href="classdtn_1_1BlockingBundleList.html#e26c8fce019eb0062f0cff1a03f4e2a3">00513</a> <a class="code" href="classdtn_1_1BlockingBundleList.html#e26c8fce019eb0062f0cff1a03f4e2a3" title="Remove (and return) the first bundle on the list, blocking (potentially limited by...">BlockingBundleList::pop_blocking</a>(<span class="keywordtype">int</span> timeout)
<a name="l00514"></a>00514 {
<a name="l00515"></a>00515     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(<a class="code" href="classdtn_1_1BundleList.html#bf8997bf56c3876e1bc96e8b2ce895e8" title="notifier for blocking list">notifier_</a>);
<a name="l00516"></a>00516 
<a name="l00517"></a>00517     log_debug(<span class="stringliteral">"pop_blocking on list %p [%s]"</span>, <span class="keyword">this</span>, <a class="code" href="classdtn_1_1BundleList.html#fe57f15c8a9270d90861739598390c78" title="Return the identifier name of this list.">name</a>().c_str());
<a name="l00518"></a>00518     
<a name="l00519"></a>00519     <a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>-&gt;lock(<span class="stringliteral">"BlockingBundleList::pop_blocking"</span>);
<a name="l00520"></a>00520 
<a name="l00521"></a>00521     <span class="keywordtype">bool</span> used_wait;
<a name="l00522"></a>00522     <span class="keywordflow">if</span> (<a class="code" href="classdtn_1_1BundleList.html#3ca5e173510164b46c8de9a95147f20d" title="Return whether or not the list is empty.">empty</a>()) {
<a name="l00523"></a>00523         used_wait = <span class="keyword">true</span>;
<a name="l00524"></a>00524         <span class="keywordtype">bool</span> notified = <a class="code" href="classdtn_1_1BundleList.html#bf8997bf56c3876e1bc96e8b2ce895e8" title="notifier for blocking list">notifier_</a>-&gt;wait(<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>, timeout);
<a name="l00525"></a>00525         <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(<a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>-&gt;is_locked_by_me());
<a name="l00526"></a>00526 
<a name="l00527"></a>00527         <span class="comment">// if the timeout occurred, wait returns false, so there's</span>
<a name="l00528"></a>00528         <span class="comment">// still nothing on the list</span>
<a name="l00529"></a>00529         <span class="keywordflow">if</span> (!notified) {
<a name="l00530"></a>00530             <a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>-&gt;unlock();
<a name="l00531"></a>00531             log_debug(<span class="stringliteral">"pop_blocking timeout on list %p"</span>, <span class="keyword">this</span>);
<a name="l00532"></a>00532 
<a name="l00533"></a>00533             <span class="keywordflow">return</span> <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a>(<span class="stringliteral">"BlockingBundleList::pop_blocking temporary"</span>);
<a name="l00534"></a>00534         }
<a name="l00535"></a>00535     } <span class="keywordflow">else</span> {
<a name="l00536"></a>00536         used_wait = <span class="keyword">false</span>;
<a name="l00537"></a>00537     }
<a name="l00538"></a>00538     
<a name="l00539"></a>00539     <span class="comment">// This can't be empty if we got notified, unless there is another</span>
<a name="l00540"></a>00540     <span class="comment">// thread waiting on the queue - which is an error.</span>
<a name="l00541"></a>00541     <a class="code" href="SDNV_8cc.html#ca68c0d4ac8df0838e209fb5300f7be3">ASSERT</a>(!<a class="code" href="classdtn_1_1BundleList.html#3ca5e173510164b46c8de9a95147f20d" title="Return whether or not the list is empty.">empty</a>());
<a name="l00542"></a>00542     
<a name="l00543"></a>00543     <a class="code" href="namespacedtn.html#87094f3b26b9f1d469e616d311ae57b1" title="Class definition for a Bundle reference.">BundleRef</a> ret(<span class="stringliteral">"BlockingBundleList::pop_blocking temporary"</span>);
<a name="l00544"></a>00544     ret = <a class="code" href="classdtn_1_1BundleList.html#265a9efd0831be3094f815eed22aec42" title="Remove (and return) a reference to the first bundle on the list.">pop_front</a>(used_wait);
<a name="l00545"></a>00545     
<a name="l00546"></a>00546     <a class="code" href="classdtn_1_1BundleList.html#be75dd18cbd95df447ff602cedd3ba0b" title="lock for notifier">lock_</a>-&gt;unlock();
<a name="l00547"></a>00547 
<a name="l00548"></a>00548     log_debug(<span class="stringliteral">"pop_blocking got bundle %p from list %p"</span>, 
<a name="l00549"></a>00549               ret.object(), <span class="keyword">this</span>);
<a name="l00550"></a>00550     
<a name="l00551"></a>00551     <span class="keywordflow">return</span> ret;
<a name="l00552"></a>00552 }
<a name="l00553"></a>00553 
<a name="l00554"></a>00554 } <span class="comment">// namespace dtn</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Fri Jan 30 09:26:52 2009 for DTN Reference Implementation by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>