#include <OSGDgramQueue.h>
Public Types | |
| typedef std::list< Dgram * > | QueueT |
Public Member Functions | |
Constructors | |
| DgramQueue (void) | |
Destructor | |
| virtual | ~DgramQueue (void) |
data put,get | |
| void | put (Dgram *dgram) |
| Dgram * | get (Lock *lock) |
| bool | empty (void) |
| void | wait (Lock *lock) |
| bool | waiting (void) |
Protected Attributes | |
member | |
| Barrier * | _barrier |
| QueueT | _queue |
| bool | _waiting |
Private Member Functions | |
| DgramQueue (const DgramQueue &source) | |
| prohibit default function (move to 'public' if needed) | |
| void | operator= (const DgramQueue &source) |
Definition at line 60 of file OSGDgramQueue.h.
| typedef std::list<Dgram*> OSG::DgramQueue::QueueT |
Definition at line 66 of file OSGDgramQueue.h.
| DgramQueue::DgramQueue | ( | void | ) |
Definition at line 67 of file OSGDgramQueue.cpp.
References _barrier, and OSG::Barrier::get().
00067 : 00068 _queue(), 00069 _waiting(false) 00070 { 00071 char barrierName[256]; 00072 sprintf(barrierName,"DgramQueue%p",this); 00073 00074 // create barrier 00075 _barrier = Barrier::get(barrierName); 00076 }
| DgramQueue::~DgramQueue | ( | void | ) | [virtual] |
| OSG::DgramQueue::DgramQueue | ( | const DgramQueue & | source | ) | [private] |
| void DgramQueue::put | ( | Dgram * | dgram | ) |
Definition at line 89 of file OSGDgramQueue.cpp.
References _barrier, _queue, _waiting, and OSG::Barrier::enter().
Referenced by OSG::GroupMCastConnection::GroupMCastConnection(), OSG::PointMCastConnection::PointMCastConnection(), OSG::PointMCastConnection::read(), OSG::PointMCastConnection::readBuffer(), OSG::PointMCastConnection::recvQueue(), OSG::GroupMCastConnection::sendQueue(), OSG::GroupMCastConnection::write(), and OSG::GroupMCastConnection::~GroupMCastConnection().
00090 { 00091 _queue.push_back(dgram); 00092 if(_waiting) 00093 { 00094 _waiting = false; 00095 _barrier->enter(2); 00096 } 00097 }
get a dgram from the queue. Block if queue is empty
Definition at line 101 of file OSGDgramQueue.cpp.
References _barrier, _queue, _waiting, OSG::Lock::acquire(), OSG::Barrier::enter(), and OSG::Lock::release().
Referenced by OSG::PointMCastConnection::read(), OSG::PointMCastConnection::readBuffer(), OSG::PointMCastConnection::recvQueue(), OSG::GroupMCastConnection::sendQueue(), OSG::GroupMCastConnection::write(), OSG::GroupMCastConnection::~GroupMCastConnection(), and OSG::PointMCastConnection::~PointMCastConnection().
00102 { 00103 Dgram *result; 00104 00105 if(_queue.empty()) 00106 { 00107 _waiting = true; 00108 lock->release(); 00109 _barrier->enter(2); 00110 lock->acquire(); 00111 } 00112 result = _queue.front(); 00113 _queue.pop_front(); 00114 00115 return result; 00116 }
| bool DgramQueue::empty | ( | void | ) |
Definition at line 138 of file OSGDgramQueue.cpp.
References _queue.
Referenced by OSG::PointMCastConnection::readBuffer(), OSG::PointMCastConnection::selectChannel(), OSG::GroupMCastConnection::sendQueue(), OSG::GroupMCastConnection::~GroupMCastConnection(), and OSG::PointMCastConnection::~PointMCastConnection().
00139 { 00140 return _queue.empty(); 00141 }
| void DgramQueue::wait | ( | Lock * | lock | ) |
wait for a dgram but dont read
Definition at line 120 of file OSGDgramQueue.cpp.
References _barrier, _queue, _waiting, OSG::Lock::acquire(), OSG::Barrier::enter(), and OSG::Lock::release().
Referenced by OSG::PointMCastConnection::selectChannel().
00121 { 00122 if(_queue.empty()) 00123 { 00124 _waiting = true; 00125 lock->release(); 00126 _barrier->enter(2); 00127 lock->acquire(); 00128 } 00129 }
| bool DgramQueue::waiting | ( | void | ) |
true, if reader is waiting
Definition at line 133 of file OSGDgramQueue.cpp.
References _waiting.
Referenced by OSG::GroupMCastConnection::write().
00134 { 00135 return _waiting; 00136 }
| void OSG::DgramQueue::operator= | ( | const DgramQueue & | source | ) | [private] |
Barrier* OSG::DgramQueue::_barrier [protected] |
Definition at line 101 of file OSGDgramQueue.h.
Referenced by DgramQueue(), get(), put(), and wait().
QueueT OSG::DgramQueue::_queue [protected] |
bool OSG::DgramQueue::_waiting [protected] |