CPN
Computational Process Networks
RemoteQueueHolder.cc
Go to the documentation of this file.
1 //=============================================================================
2 // Computational Process Networks class library
3 // Copyright (C) 1997-2006 Gregory E. Allen and The University of Texas
4 //
5 // This library is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU Library General Public License as published
7 // by the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Library General Public License for more details.
14 //
15 // The GNU Public License is available in the file LICENSE, or you
16 // can write to the Free Software Foundation, Inc., 59 Temple Place -
17 // Suite 330, Boston, MA 02111-1307, USA, or you can find it on the
18 // World Wide Web at http://www.fsf.org.
19 //=============================================================================
23 #include "common_priv.h"
24 #include "RemoteQueueHolder.h"
25 #include <cpn/utils/AutoLock.h>
26 
27 namespace CPN {
28 
29  void RemoteQueueHolder::AddQueue(shared_ptr<RemoteQueueBase> queue) {
31  queuemap.insert(std::make_pair(queue->GetKey(), queue));
32  }
33 
36  QueueMap::iterator entry = queuemap.find(key);
37  if (entry != queuemap.end()) {
38  queuelist.push_back(entry->second);
39  queuemap.erase(entry);
40  }
41  cond.Signal();
42  }
43 
46  QueueList tmp;
47  tmp.swap(queuelist);
48  al.Unlock();
49  tmp.clear();
50  }
51 
54  QueueMap::iterator q = queuemap.begin();
55  while (q != queuemap.end()) {
56  q->second->Shutdown();
57  ++q;
58  }
60  while (!queuemap.empty()) {
61  cond.Wait(lock);
62  }
63  queuelist.clear();
64  }
65 
67  QueueMap::iterator q = queuemap.begin();
68  while (q != queuemap.end()) {
69  q->second->LogState();
70  ++q;
71  }
72  QueueList::iterator itr = queuelist.begin();
73  while (itr != queuelist.end()) {
74  itr->get()->LogState();
75  ++itr;
76  }
77  }
78 }
79 
PthreadCondition & Wait(PthreadMutex &mutex)
void Unlock()
Definition: AutoLock.h:61
uint64_t Key_t
Definition: common.h:79
An object to hold references to RemoteQueues so they can continue to work after the node has gone awa...
void SendWakeup()
Causes this handler to become readable any Poll on this FileHandler will then return.
Definition: WakeupHandle.cc:50
void AddQueue(shared_ptr< RemoteQueueBase > queue)
void CleanupQueue(Key_t key)
std::vector< shared_ptr< RemoteQueueBase > > QueueList
PthreadCondition & Signal(void)
Automatic locking on the stack.