Planeshift
Public Member Functions | Protected Attributes

GenericRefQueue< queuetype, refType > Class Template Reference

A queue of smart pointers with locking facilties for multi-threading. More...

#include <genrefqueue.h>

List of all members.

Public Member Functions

bool Add (queuetype *msg)
 This adds a message to the queue and waits if it is full.
bool AddWait (queuetype *msg, csTicks timeout=0)
 like above, but waits to add the next message, if the queue is full be careful with this.
unsigned int Count ()
 Number of items in the queue.
 GenericRefQueue (unsigned int maxsize=500)
csPtr< queuetype > Get ()
 This gets the next message from the queue, it is then removed from the queue.
csPtr< queuetype > GetWait (csTicks timeout)
 like above, but waits for the next message, if the queue is empty
void Interrupt ()
 This function interrupt the queue if it is waiting.
bool IsFull ()
csPtr< queuetype > Peek ()
 ~GenericRefQueue ()

Protected Attributes

CS::Threading::Condition datacondition
CS::Threading::RecursiveMutex mutex
refType< queuetype > * qbuffer
unsigned int qend
unsigned int qsize
unsigned int qstart

Detailed Description

template<class queuetype, template< class T > class refType = csRef>
class GenericRefQueue< queuetype, refType >

A queue of smart pointers with locking facilties for multi-threading.

The objects in the queue must implement reference counting.

Definition at line 39 of file genrefqueue.h.


Constructor & Destructor Documentation

template<class queuetype, template< class T > class refType = csRef>
GenericRefQueue< queuetype, refType >::GenericRefQueue ( unsigned int  maxsize = 500) [inline]

Definition at line 42 of file genrefqueue.h.

template<class queuetype, template< class T > class refType = csRef>
GenericRefQueue< queuetype, refType >::~GenericRefQueue ( ) [inline]

Definition at line 51 of file genrefqueue.h.


Member Function Documentation

template<class queuetype, template< class T > class refType = csRef>
bool GenericRefQueue< queuetype, refType >::Add ( queuetype *  msg) [inline]

This adds a message to the queue and waits if it is full.

Definition at line 82 of file genrefqueue.h.

template<class queuetype, template< class T > class refType = csRef>
bool GenericRefQueue< queuetype, refType >::AddWait ( queuetype *  msg,
csTicks  timeout = 0 
) [inline]

like above, but waits to add the next message, if the queue is full be careful with this.

It's easy to deadlock!

Definition at line 58 of file genrefqueue.h.

template<class queuetype, template< class T > class refType = csRef>
unsigned int GenericRefQueue< queuetype, refType >::Count ( ) [inline]

Number of items in the queue.

Definition at line 207 of file genrefqueue.h.

template<class queuetype, template< class T > class refType = csRef>
csPtr<queuetype> GenericRefQueue< queuetype, refType >::Get ( ) [inline]

This gets the next message from the queue, it is then removed from the queue.

Note: It returns a pointer to the message, so a null pointer indicates an error

Definition at line 142 of file genrefqueue.h.

template<class queuetype, template< class T > class refType = csRef>
csPtr<queuetype> GenericRefQueue< queuetype, refType >::GetWait ( csTicks  timeout) [inline]

like above, but waits for the next message, if the queue is empty

Definition at line 172 of file genrefqueue.h.

template<class queuetype, template< class T > class refType = csRef>
void GenericRefQueue< queuetype, refType >::Interrupt ( ) [inline]

This function interrupt the queue if it is waiting.

Definition at line 199 of file genrefqueue.h.

template<class queuetype, template< class T > class refType = csRef>
bool GenericRefQueue< queuetype, refType >::IsFull ( ) [inline]

Definition at line 216 of file genrefqueue.h.

template<class queuetype, template< class T > class refType = csRef>
csPtr<queuetype> GenericRefQueue< queuetype, refType >::Peek ( ) [inline]

Definition at line 111 of file genrefqueue.h.


Member Data Documentation

template<class queuetype, template< class T > class refType = csRef>
CS::Threading::Condition GenericRefQueue< queuetype, refType >::datacondition [protected]

Definition at line 226 of file genrefqueue.h.

template<class queuetype, template< class T > class refType = csRef>
CS::Threading::RecursiveMutex GenericRefQueue< queuetype, refType >::mutex [protected]

Definition at line 225 of file genrefqueue.h.

template<class queuetype, template< class T > class refType = csRef>
refType<queuetype>* GenericRefQueue< queuetype, refType >::qbuffer [protected]

Definition at line 223 of file genrefqueue.h.

template<class queuetype, template< class T > class refType = csRef>
unsigned int GenericRefQueue< queuetype, refType >::qend [protected]

Definition at line 224 of file genrefqueue.h.

template<class queuetype, template< class T > class refType = csRef>
unsigned int GenericRefQueue< queuetype, refType >::qsize [protected]

Definition at line 224 of file genrefqueue.h.

template<class queuetype, template< class T > class refType = csRef>
unsigned int GenericRefQueue< queuetype, refType >::qstart [protected]

Definition at line 224 of file genrefqueue.h.


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