#include <RioQueue.h>
Public Member Functions | |
RioQueue () | |
~RioQueue () | |
void | Put (RioQueueEle *ep) |
RioQueueEle * | Get () |
RioQueueEle * | Remove () |
RioQueue () | |
~RioQueue () | |
void | Put (RioQueueEle *ep) |
RioQueueEle * | Get () |
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 |
RioQueueEle * | m_top |
RioQueueEle * | m_bot |
RioQueueEle * | m_sync |
Private Member Functions | |
RioQueue (const RioQueue &x) | |
RioQueue & | operator= (const RioQueue &x) |
Private Attributes | |
CvsiCondition | m_cond |
int | m_Signal |
RioQueueEle * | m_first |
RioQueueEle * | m_last |
Definition at line 43 of file RioQueue.h.
RioQueue::RioQueue | ( | const RioQueue & | x | ) | [private] |
RioQueue::RioQueue | ( | ) |
Definition at line 47 of file RioQueue.cpp.
RioQueue::~RioQueue | ( | ) |
Definition at line 59 of file RioQueue.cpp.
RioQueue::RioQueue | ( | ) |
RioQueue::~RioQueue | ( | ) |
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 }
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.h.
CvsiCondition RioQueue::m_cond [private] |
Definition at line 63 of file rioqueue.h.
pthread_cond_t RioQueue::m_cond |
Definition at line 52 of file RioQueue.h.
RioQueueEle* RioQueue::m_first [private] |
Definition at line 66 of file rioqueue.h.
Definition at line 55 of file RioQueue.h.
RioQueueEle * RioQueue::m_last [private] |
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.