Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

osg::DgramQueue Class Reference
[Network]

Stream socket connection.

#include <OSGDgramQueue.h>

List of all members.

Public Types

typedef std::list< Dgram * > QueueT

Public Member Functions

Constructors
DgramQueue ()
Destructor
*virtual ~DgramQueue ()
data put,get
*void put (Dgram *dgram)
Dgramget (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)


Detailed Description

Definition at line 60 of file OSGDgramQueue.h.


Member Typedef Documentation

typedef std::list<Dgram*> osg::DgramQueue::QueueT
 

Definition at line 65 of file OSGDgramQueue.h.


Constructor & Destructor Documentation

DgramQueue::DgramQueue  ) 
 

Constructor size must be 2^x

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  )  [virtual]
 

Destructor

Definition at line 80 of file OSGDgramQueue.cpp.

00081 {
00082 }

osg::DgramQueue::DgramQueue const DgramQueue source  )  [private]
 


Member Function Documentation

void DgramQueue::put Dgram dgram  ) 
 

put a dgram to the queue.

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 }

Dgram * DgramQueue::get Lock lock  ) 
 

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::aquire(), 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->aquire();
00111     }
00112     result = _queue.front();
00113     _queue.pop_front();
00114 
00115     return result;
00116 }

bool DgramQueue::empty void   ) 
 

put a dgram to the queue.

Definition at line 138 of file OSGDgramQueue.cpp.

References _queue.

Referenced by osg::PointMCastConnection::readBuffer(), 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::aquire(), osg::Barrier::enter(), and osg::Lock::release().

00121 {
00122     if(_queue.empty())
00123     {
00124         _waiting = true;
00125         lock->release();
00126         _barrier->enter(2);
00127         lock->aquire();
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]
 


Member Data Documentation

* Barrier* osg::DgramQueue::_barrier [protected]
 

Definition at line 99 of file OSGDgramQueue.h.

Referenced by DgramQueue(), get(), put(), and wait().

QueueT osg::DgramQueue::_queue [protected]
 

Definition at line 100 of file OSGDgramQueue.h.

Referenced by empty(), get(), put(), and wait().

bool osg::DgramQueue::_waiting [protected]
 

Definition at line 101 of file OSGDgramQueue.h.

Referenced by get(), put(), wait(), and waiting().


The documentation for this class was generated from the following files:
Generated on Thu Aug 25 04:12:52 2005 for OpenSG by  doxygen 1.4.3