MAK RTIspy API Documentation for HLA 1.3
Public Types | Public Member Functions | Protected Attributes
DtThreadSafeBufferQueue< T > Class Template Reference

Very simple wrapper that provides thread-safe access to a basic queue of buffers. More...

+ Inheritance diagram for DtThreadSafeBufferQueue< T >:
+ Collaboration diagram for DtThreadSafeBufferQueue< T >:

List of all members.

Public Types

typedef std::vector< T > Buffer
typedef std::deque< Buffer * > BufferQueue

Public Member Functions

 DtThreadSafeBufferQueue (unsigned int initialBufferSize=1000, unsigned int initialBufferCount=10)
 Ctor.
virtual ~DtThreadSafeBufferQueue ()
 Dtor.
virtual void push (const T *buff, unsigned int size)
 Push a copy of a T[] of size elements onto the back of the queue.
virtual void push (Buffer buff)
 Push a copy of a buffer onto the back of the queue.
virtual std::auto_ptr< Bufferpop ()
 Pop the next buffer from the front of the queue Popper assumes ownership of popped buffer.
virtual void releaseBuffer (std::auto_ptr< Buffer > buff)
 Return ownership of a buffer to the Queue for re-use.
virtual size_t size () const

Protected Attributes

BufferQueue myQueue
 Data Members.
BufferQueue myFreeBuffers
MAKRti::DtMutex myLock
 Lock for critical section access.

Detailed Description

template<class T>
class DtThreadSafeBufferQueue< T >

Very simple wrapper that provides thread-safe access to a basic queue of buffers.

Queue always makes a complete copy of the pushed buffer. Each buffer element must be copyable. Ownership of popped buffers is assumed by the "popper". Popped buffers may be released to return ownership to the Queue for reuse.

Warning:
Passing a buffer of pointers will break the Thread-Safety guarantee.
This class is definitely not an STL compliant template and it is
not 100% exception safe (lock may remain locked)

Member Typedef Documentation

template<class T>
typedef std::vector<T> DtThreadSafeBufferQueue< T >::Buffer
template<class T>
typedef std::deque<Buffer*> DtThreadSafeBufferQueue< T >::BufferQueue

Constructor & Destructor Documentation

template<class T>
DtThreadSafeBufferQueue< T >::DtThreadSafeBufferQueue ( unsigned int  initialBufferSize = 1000,
unsigned int  initialBufferCount = 10 
)

Ctor.

template<class T>
virtual DtThreadSafeBufferQueue< T >::~DtThreadSafeBufferQueue ( ) [virtual]

Dtor.


Member Function Documentation

template<class T>
virtual std::auto_ptr< Buffer > DtThreadSafeBufferQueue< T >::pop ( ) [inline, virtual]

Pop the next buffer from the front of the queue Popper assumes ownership of popped buffer.

Returns 0 if queue is empty

Referenced by DtExtendedRtiMsgForwarder::getNextMsg().

template<class T>
virtual void DtThreadSafeBufferQueue< T >::push ( const T *  buff,
unsigned int  size 
) [inline, virtual]

Push a copy of a T[] of size elements onto the back of the queue.

Referenced by DtMessageBufferFilter::doFilter(), DtExtendedRtiMsgForwarder::getNextMsg(), and DtExtendedRtiMsgForwarder::sendMessageToWan().

template<class T>
virtual void DtThreadSafeBufferQueue< T >::push ( Buffer  buff) [inline, virtual]

Push a copy of a buffer onto the back of the queue.

template<class T>
virtual void DtThreadSafeBufferQueue< T >::releaseBuffer ( std::auto_ptr< Buffer buff) [inline, virtual]

Return ownership of a buffer to the Queue for re-use.

Referenced by DtExtendedRtiMsgForwarder::getNextMsg().

template<class T>
virtual size_t DtThreadSafeBufferQueue< T >::size ( ) const [inline, virtual]

Member Data Documentation

template<class T>
BufferQueue DtThreadSafeBufferQueue< T >::myFreeBuffers [protected]
template<class T>
MAKRti::DtMutex DtThreadSafeBufferQueue< T >::myLock [mutable, protected]

Lock for critical section access.

template<class T>
BufferQueue DtThreadSafeBufferQueue< T >::myQueue [protected]

Data Members.


The documentation for this class was generated from the following file:

Document ID: Generated on Thu Jun 14 14:15:04 EDT 2012 from SVN revision 116116
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)