RioQueue Class Reference

#include <RioQueue.h>

Public Member Functions

 RioQueue ()
 ~RioQueue ()
void Put (RioQueueEle *ep)
RioQueueEleGet ()
RioQueueEleRemove ()
 RioQueue ()
 ~RioQueue ()
void Put (RioQueueEle *ep)
RioQueueEleGet ()
void Signal ()
bool Test ()

Data Fields

pthread_mutex_t m_mutex
pthread_cond_t m_cond
int m_waitflag
int m_waitcnt
int m_getcnt
RioQueueElem_top
RioQueueElem_bot
RioQueueElem_sync

Private Member Functions

 RioQueue (const RioQueue &x)
RioQueueoperator= (const RioQueue &x)

Private Attributes

CvsiCondition m_cond
int m_Signal
RioQueueElem_first
RioQueueElem_last

Detailed Description

Definition at line 43 of file RioQueue.h.


Constructor & Destructor Documentation

RioQueue::RioQueue ( const RioQueue x  )  [private]
RioQueue::RioQueue (  ) 

Definition at line 47 of file RioQueue.cpp.

00048 {
00049     pthread_mutex_init( &m_mutex, NULL );
00050     pthread_cond_init( &m_cond, NULL );
00051     m_waitflag  = 0;
00052     m_waitcnt   = 0;
00053     m_getcnt    = 0;
00054     m_top       = NULL;
00055     m_bot       = VIRTORG( m_top, RioQueueEle, linkf );
00056     m_sync      = NULL;
00057 }

RioQueue::~RioQueue (  ) 

Definition at line 59 of file RioQueue.cpp.

00060 {
00061     pthread_mutex_destroy( &m_mutex );
00062     pthread_cond_destroy( &m_cond );
00063 }

RioQueue::RioQueue (  ) 
RioQueue::~RioQueue (  ) 

Member Function Documentation

RioQueueEle* RioQueue::Get (  ) 
RioQueueEle * RioQueue::Get ( void   ) 

Definition at line 84 of file RioQueue.cpp.

00085 {
00086     RioQueueEle *ep;
00087 
00088     pthread_mutex_lock( &m_mutex );
00089 
00090     m_getcnt++;
00091 
00092     if( m_top == 0 )
00093         m_waitcnt++;
00094 
00095     while( m_top == 0 )
00096     {
00097         m_waitflag = 1;
00098         pthread_cond_wait( &m_cond, &m_mutex );
00099     }
00100 
00101     m_waitflag = 0;
00102     ep         = m_top;
00103     m_top      = ep->linkf;
00104 
00105     if( m_top == 0 )
00106         m_bot = VIRTORG( m_top, RioQueueEle, linkf );
00107 
00108     pthread_mutex_unlock( &m_mutex );
00109 
00110     return ep;
00111 }

RioQueue& RioQueue::operator= ( const RioQueue x  )  [private]
void RioQueue::Put ( RioQueueEle ep  ) 
void RioQueue::Put ( RioQueueEle ep  ) 

Definition at line 66 of file RioQueue.cpp.

00067 {
00068     pthread_mutex_lock( &m_mutex );
00069 
00070     ep->linkf    = 0;
00071     m_bot->linkf = ep;
00072     m_bot        = ep;
00073 
00074     if( m_waitflag )
00075     {
00076         pthread_cond_broadcast( &m_cond );
00077         m_waitflag = 0;
00078     }
00079 
00080     pthread_mutex_unlock( &m_mutex );
00081 }

RioQueueEle * RioQueue::Remove ( void   ) 

Definition at line 115 of file RioQueue.cpp.

00116 {
00117     RioQueueEle *ep;
00118 
00119     pthread_mutex_lock( &m_mutex );
00120 
00121     if( m_top == 0 )
00122         ep = NULL;
00123     else
00124     {
00125         ep         = m_top;
00126         m_top      = ep->linkf;
00127 
00128         if( m_top == 0 )
00129             m_bot = VIRTORG( m_top, RioQueueEle, linkf );
00130 
00131     }
00132 
00133     pthread_mutex_unlock( &m_mutex );
00134 
00135     return ep;
00136 }

void RioQueue::Signal (  ) 

Definition at line 154 of file rioqueue.cpp.

00155 {
00156     m_cond.Lock();
00157     if(m_waitflag)
00158     {
00159         // Set flag that causes Get() to stop waiting element and to return a
00160         // null pointer
00161         m_Signal = 1;
00162         // Signal condition variable to unblock thread waiting on Get()
00163         m_cond.Signal();
00164         m_waitflag = 0;
00165     }
00166     m_cond.Unlock();
00167 }

bool RioQueue::Test (  ) 

Definition at line 57 of file rioqueue.cpp.

00058 {
00059     bool Result;
00060     m_cond.Lock();
00061 
00062     if( (m_sync == 0) && (m_first == 0) )
00063         Result = false;
00064     else
00065         Result = true;
00066     m_cond.Unlock();
00067 
00068     return Result;
00069 }


Field Documentation

Definition at line 57 of file RioQueue.h.

Definition at line 63 of file rioqueue.h.

pthread_cond_t RioQueue::m_cond

Definition at line 52 of file RioQueue.h.

Definition at line 66 of file rioqueue.h.

Definition at line 55 of file RioQueue.h.

Definition at line 66 of file rioqueue.h.

pthread_mutex_t RioQueue::m_mutex

Definition at line 51 of file RioQueue.h.

int RioQueue::m_Signal [private]

Definition at line 65 of file rioqueue.h.

Definition at line 58 of file RioQueue.h.

Definition at line 56 of file RioQueue.h.

Definition at line 54 of file RioQueue.h.

Definition at line 53 of file RioQueue.h.


The documentation for this class was generated from the following files:
Generated on Wed Jul 4 16:03:36 2012 for RIO by  doxygen 1.6.3