Mixe for Privacy and Anonymity in the Internet
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
CAQueue Class Reference

This is a simple FIFO-Queue. More...

#include <CAQueue.hpp>

Collaboration diagram for CAQueue:

Public Member Functions

 CAQueue (UINT32 expectedElementSize=0)
 Give the size of the amount of data what you will add in one step. More...
 
 ~CAQueue ()
 Deletes this Queue and all stored data. More...
 
SINT32 add (const void *buff, UINT32 size)
 Adds data to the Queue. More...
 
SINT32 close ()
 Closes the Queue (for writing). More...
 
SINT32 get (UINT8 *pbuff, UINT32 *psize)
 Gets up to psize number of bytes from the Queue. More...
 
SINT32 getOrWait (UINT8 *pbuff, UINT32 *psize)
 Gets data from the Queue or waits until some data is available, if the Queue is empty. More...
 
SINT32 getOrWait (UINT8 *pbuff, UINT32 *psize, UINT32 msTimeOut)
 Gets data from the Queue or waits until some data is available, if the Queue is empty or a timeout is reached. More...
 
SINT32 peek (UINT8 *pbuff, UINT32 *psize)
 Peeks data from the Queue. More...
 
SINT32 remove (UINT32 *psize)
 Removes data from the Queue. More...
 
SINT32 clean ()
 Removes any stored data from the Queue. More...
 
UINT32 getSize ()
 Returns the size of stored data in byte. More...
 
UINT32 getSizeLookFree ()
 Returns the size of stored data in byte. More...
 
bool isEmpty ()
 Returns true, if the Queue is empty. More...
 
bool isClosed ()
 Returns true, if the Queue is closed. More...
 

Static Public Member Functions

static SINT32 test ()
 Method to test the Queue. More...
 

Private Attributes

volatile QUEUEm_Queue
 
volatile QUEUEm_lastElem
 
volatile UINT32 m_nQueueSize
 
volatile bool m_bClosed
 
UINT32 m_nExpectedElementSize
 
CAMutexm_pcsQueue
 
CAConditionVariablem_pconvarSize
 

Detailed Description

This is a simple FIFO-Queue.

You can add data and get them back. This class is thread safe. TODO: The handling of getAndWait is not correct because remove could intercept.... Maybe we do not neeed an other Mutex other than then ConVar....

Definition at line 49 of file CAQueue.hpp.

Constructor & Destructor Documentation

◆ CAQueue()

CAQueue::CAQueue ( UINT32  expectedElementSize = 0)
inline

Give the size of the amount of data what you will add in one step.

Used for optimizations. Use expectedElementSize=0, if you have no idea about the typicall amount of data added in one call to add().

Definition at line 57 of file CAQueue.hpp.

58  {
59  m_Queue=NULL;
60  m_lastElem=NULL;
61  m_nExpectedElementSize=expectedElementSize;
62  m_nQueueSize=0;
63  m_pcsQueue=new CAMutex();
65  m_bClosed=false;
66 #ifdef QUEUE_SIZE_LOG
67  m_nLogSize=0;
68 #endif
69  //m_pHeap=NULL;
70  //incHeap();
71  }
CAConditionVariable * m_pconvarSize
Definition: CAQueue.hpp:159
CAMutex * m_pcsQueue
Definition: CAQueue.hpp:158
volatile UINT32 m_nQueueSize
Definition: CAQueue.hpp:154
volatile bool m_bClosed
Definition: CAQueue.hpp:155
volatile QUEUE * m_lastElem
Definition: CAQueue.hpp:153
volatile QUEUE * m_Queue
Definition: CAQueue.hpp:152
UINT32 m_nExpectedElementSize
Definition: CAQueue.hpp:156

References m_bClosed, m_lastElem, m_nExpectedElementSize, m_nQueueSize, m_pconvarSize, m_pcsQueue, and m_Queue.

Referenced by test().

Here is the caller graph for this function:

◆ ~CAQueue()

CAQueue::~CAQueue ( )

Deletes this Queue and all stored data.

Definition at line 36 of file CAQueue.cpp.

37  {
38  clean();
39  delete m_pcsQueue;
40  m_pcsQueue = NULL;
41  delete m_pconvarSize;
42  m_pconvarSize = NULL;
43  }
SINT32 clean()
Removes any stored data from the Queue.
Definition: CAQueue.cpp:47

References clean(), m_pconvarSize, and m_pcsQueue.

Here is the call graph for this function:

Member Function Documentation

◆ add()

SINT32 CAQueue::add ( const void *  buff,
UINT32  size 
)

Adds data to the Queue.

Parameters
buffpointer to the data buffer
sizesize of data to add
Return values
E_UNKNOWNin case of an error
E_SUCCESSif succesful

Definition at line 76 of file CAQueue.cpp.

77  {
78  if(size==0)
79  return E_SUCCESS;
80  if(buff==NULL)
81  return E_UNKNOWN;
82  if (m_bClosed)
83  return E_UNKNOWN;
84  QUEUE* newEntry = new QUEUE;
85  newEntry->pBuff=new UINT8[size];
86  newEntry->next=NULL;
87  newEntry->size=size;
88  newEntry->index=0;
89  memcpy(newEntry->pBuff,buff,size);
90  m_pcsQueue->lock();
91  //if(m_pHeap==NULL)
92  // incHeap();
93 #ifdef _DEBUG
94 // if(m_nExpectedElementSize>0&&size>(m_nExpectedElementSize<<1))
95  /*if(size>1500)
96  {
97  CAMsg::printMsg(LOG_DEBUG,"CAQueue::add() WARNING: request for add %u bytes in a queue with expected element size of %u bytes !\n",size,m_nExpectedElementSize);
98  }*/
99 #endif
100  if(m_Queue==NULL)
101  {
102  /*m_Queue=m_pHeap;
103  m_pHeap=m_pHeap->next;
104  if(size>m_nExpectedElementSize)
105  {
106  delete[] m_Queue->pBuff;
107  m_Queue->pBuff=new UINT8[size];
108  }*/
109  m_Queue=newEntry;
111  }
112  else
113  {
114 /* m_lastElem->next=m_pHeap;
115  m_lastElem=m_pHeap;
116  m_pHeap=m_pHeap->next;
117  if(size>m_nExpectedElementSize)
118  {
119  delete[] m_lastElem->pBuff;
120  m_lastElem->pBuff=new UINT8[size];
121  }*/
122  m_lastElem->next=newEntry;
123  m_lastElem=newEntry;
124  }
125  m_nQueueSize+=size;
126 #ifdef QUEUE_SIZE_LOG
127  if(m_nLogSize!=0 && m_nQueueSize>m_nLogSize)
128  {
129  CAMsg::printMsg(LOG_DEBUG,"CAQueue::add() WARNING: queue size is now %u bytes which is above the expected maximum size of %u\n !\n",m_nQueueSize,m_nLogSize);
130  }
131 #endif
132  m_pcsQueue->unlock();
133  m_pconvarSize->lock();
136  return E_SUCCESS;
137  }
struct _t_queue QUEUE
Definition: CAQueue.hpp:42
unsigned char UINT8
Definition: basetypedefs.h:135
SINT32 signal()
Signals this object.
static SINT32 printMsg(UINT32 typ, const char *format,...)
Writes a given message to the log.
Definition: CAMsg.cpp:251
SINT32 unlock()
Definition: CAMutex.hpp:52
SINT32 lock()
Definition: CAMutex.hpp:41
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2
#define E_UNKNOWN
Definition: errorcodes.hpp:3
UINT8 * pBuff
Definition: CAQueue.hpp:36
UINT32 size
Definition: CAQueue.hpp:38
UINT32 index
Definition: CAQueue.hpp:39
struct _t_queue * next
Definition: CAQueue.hpp:37

References E_SUCCESS, E_UNKNOWN, _t_queue::index, CAMutex::lock(), m_bClosed, m_lastElem, m_nQueueSize, m_pconvarSize, m_pcsQueue, m_Queue, _t_queue::next, _t_queue::pBuff, CAMsg::printMsg(), CAConditionVariable::signal(), _t_queue::size, and CAMutex::unlock().

Referenced by CAChain::addDataToUpstreamQueue(), CAFirstMix::clean(), CALastMix::clean(), CAFirstMixA::closeConnection(), MemFormatTarget::dumpMem(), CAFirstMixA::loop(), CALastMixA::loop(), CAFirstMixB::loop(), CALastMixB::loop(), CAFirstMixA::notifyAllUserChannels(), producer(), CAMiddleMix::putMixPacketIntoQueueSendToMixBefore(), CAControlChannelDispatcher::sendMessages(), test(), and MemFormatTarget::writeChars().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clean()

SINT32 CAQueue::clean ( )

Removes any stored data from the Queue.

Definition at line 47 of file CAQueue.cpp.

48  {
49  m_pcsQueue->lock();
50  while(m_Queue!=NULL)
51  {
52  delete[] m_Queue->pBuff;
53  m_Queue->pBuff = NULL;
56  delete m_lastElem;
57  }
58 /* while(m_pHeap!=NULL)
59  {
60  delete[] m_pHeap->pBuff;
61  m_lastElem=m_pHeap;
62  m_pHeap=m_pHeap->next;
63  delete m_lastElem;
64  }*/
65  m_nQueueSize=0;
66  m_lastElem=NULL;
67  m_pcsQueue->unlock();
68  return E_SUCCESS;
69  }

References E_SUCCESS, CAMutex::lock(), m_lastElem, m_nQueueSize, m_pcsQueue, m_Queue, _t_queue::next, _t_queue::pBuff, and CAMutex::unlock().

Referenced by CAFirstMixA::checkUserConnections(), CAChain::closeChainInternal(), CAChain::~CAChain(), and ~CAQueue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ close()

SINT32 CAQueue::close ( )
inline

Closes the Queue (for writing).

One can still read the remaing bytes out of the queue.

Definition at line 77 of file CAQueue.hpp.

78  {
79  m_pcsQueue->lock();
80  m_bClosed=true;
81  m_pcsQueue->unlock();
82  if (m_Queue == NULL) //signal possible reader that the queue ist closed...
83  {
87  }
88  return E_SUCCESS;
89  }

References E_SUCCESS, CAMutex::lock(), m_bClosed, m_pconvarSize, m_pcsQueue, m_Queue, CAConditionVariable::signal(), and CAMutex::unlock().

Referenced by CALastMixA::loop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get()

SINT32 CAQueue::get ( UINT8 pbuff,
UINT32 psize 
)

Gets up to psize number of bytes from the Queue.

The data is removed from the Queue.

Parameters
pbuffpointer to a buffer, there the data should be stored
psizeon call contains the size of pbuff, on return contains the size of returned data
Return values
E_SUCCESSif succesful
E_CLOSEDif the queue is empty and closed
E_UNKNOWNin case of an error

Definition at line 148 of file CAQueue.cpp.

149  {
150  if(pbuff==NULL||psize==NULL)
151  return E_UNKNOWN;
152  if(*psize==0)
153  return E_SUCCESS;
154  if(m_Queue==NULL)
155  {
156  *psize=0;
157  if ((m_bClosed))
158  {
159  return E_CLOSED;
160  }
161  return E_SUCCESS;
162  }
163  m_pcsQueue->lock();
164  UINT32 space=*psize;
165  *psize=0;
166  while(space>=m_Queue->size)
167  {
168  memcpy(pbuff,m_Queue->pBuff+m_Queue->index,m_Queue->size);
169  *psize+=m_Queue->size;
170  pbuff+=m_Queue->size;
171  space-=m_Queue->size;
173  QUEUE* tmp=(QUEUE*)m_Queue;
175  //tmp->next=m_pHeap;
176  //m_pHeap=tmp;
177  delete[] tmp->pBuff;
178  tmp->pBuff = NULL;
179  delete tmp;
180  if(m_Queue==NULL)
181  {
182  m_pcsQueue->unlock();
183  return E_SUCCESS;
184  }
185  }
186  if(space>0)
187  {
188  memcpy(pbuff,m_Queue->pBuff+m_Queue->index,space);
189  *psize+=space;
190  m_Queue->size-=space;
191  m_Queue->index+=space;
192  m_nQueueSize-=space;
193  //memmove(m_Queue->pBuff,m_Queue->pBuff+space,m_Queue->size);
194  }
195  m_pcsQueue->unlock();
196  return E_SUCCESS;
197  }
unsigned int UINT32
Definition: basetypedefs.h:131
#define E_CLOSED
Definition: errorcodes.hpp:5

References E_CLOSED, E_SUCCESS, E_UNKNOWN, _t_queue::index, CAMutex::lock(), m_bClosed, m_nQueueSize, m_pcsQueue, m_Queue, _t_queue::next, _t_queue::pBuff, _t_queue::size, and CAMutex::unlock().

Referenced by CAFirstMix::doUserLogin_internal(), getOrWait(), CAFirstMixA::loop(), CALastMixA::loop(), CAFirstMixB::loop(), CALastMixB::loop(), CAFirstMixA::sendToUsers(), and test().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOrWait() [1/2]

SINT32 CAQueue::getOrWait ( UINT8 pbuff,
UINT32 psize 
)

Gets data from the Queue or waits until some data is available, if the Queue is empty.

The data is removed from the Queue.

Parameters
pbuffpointer to a buffer, there the data should be stored
psizeon call contains the size of pbuff, on return contains the size of returned data
Return values
E_SUCCESSif succesful
E_CLOSEDif the queue is empty and closed
E_UNKNOWNin case of an error

Definition at line 209 of file CAQueue.cpp.

210  {
211  m_pconvarSize->lock();
212  while (m_Queue == NULL&&!m_bClosed)
213  {
214  m_pconvarSize->wait();
215  }
216  SINT32 ret=get(pbuff,psize);
218  return ret;
219  }
signed int SINT32
Definition: basetypedefs.h:132
SINT32 wait()
Waits for a signal or for a timeout.
SINT32 get(UINT8 *pbuff, UINT32 *psize)
Gets up to psize number of bytes from the Queue.
Definition: CAQueue.cpp:148

References get(), CAMutex::lock(), m_bClosed, m_pconvarSize, m_Queue, CAMutex::unlock(), and CAConditionVariable::wait().

Referenced by consumer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOrWait() [2/2]

SINT32 CAQueue::getOrWait ( UINT8 pbuff,
UINT32 psize,
UINT32  msTimeout 
)

Gets data from the Queue or waits until some data is available, if the Queue is empty or a timeout is reached.

The data is removed from the Queue.

Parameters
pbuffpointer to a buffer, there the data should be stored
psizeon call contains the size of pbuff, on return contains the size of returned data
msTimeouttimeout in milli seconds
Return values
E_SUCCESSif succesful
E_TIMEDOUTif timeout was reached
E_UNKNOWNin case of an error

Definition at line 232 of file CAQueue.cpp.

233  {
234  m_pconvarSize->lock();
235  SINT32 ret;
236  while(m_Queue==NULL)
237  {
238  ret=m_pconvarSize->wait(msTimeout);
239  if(ret==E_TIMEDOUT)
240  {
242  return E_TIMEDOUT;
243  }
244  }
245  ret=get(pbuff,psize);
247  return ret;
248  }
#define E_TIMEDOUT
Definition: errorcodes.hpp:10

References E_TIMEDOUT, get(), CAMutex::lock(), m_pconvarSize, m_Queue, CAMutex::unlock(), and CAConditionVariable::wait().

Here is the call graph for this function:

◆ getSize()

UINT32 CAQueue::getSize ( )
inline

Returns the size of stored data in byte.

Returns
size of Queue

Definition at line 101 of file CAQueue.hpp.

102  {
103  if (m_pcsQueue)
104  {
105  m_pcsQueue->lock();
107  m_pcsQueue->unlock();
108  return s;
109  }
110  return 0;
111  }

References CAMutex::lock(), m_nQueueSize, m_pcsQueue, and CAMutex::unlock().

Referenced by CAFirstMixA::checkUserConnections(), CAFirstMix::doUserLogin_internal(), MemFormatTarget::dumpMem(), CAFirstMixA::loop(), CALastMixA::loop(), CAFirstMixB::loop(), CALastMixB::loop(), CAFirstMixA::sendToUsers(), and test().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSizeLookFree()

UINT32 CAQueue::getSizeLookFree ( )
inline

Returns the size of stored data in byte.

This is the look free version which might return a slighty wrong result due to concurrent changes in the queue.

Returns
size of Queue

Definition at line 116 of file CAQueue.hpp.

117  {
118  return m_nQueueSize;
119  }

References m_nQueueSize.

Referenced by CALastMixA::loop().

Here is the caller graph for this function:

◆ isClosed()

bool CAQueue::isClosed ( )
inline

Returns true, if the Queue is closed.

Return values
true,ifQueue is closed
false,otherwise

Definition at line 134 of file CAQueue.hpp.

135  {
136  return m_bClosed;
137  }

References m_bClosed.

Referenced by CALastMixA::loop().

Here is the caller graph for this function:

◆ isEmpty()

bool CAQueue::isEmpty ( )
inline

Returns true, if the Queue is empty.

Return values
true,ifQueue is empty
false,ifQueue contains data

Definition at line 125 of file CAQueue.hpp.

126  {
127  return (m_Queue==NULL);
128  }

References m_Queue.

Referenced by CALastMixA::loop(), CAChain::sendUpstreamData(), and test().

Here is the caller graph for this function:

◆ peek()

SINT32 CAQueue::peek ( UINT8 pbuff,
UINT32 psize 
)

Peeks data from the Queue.

The data is NOT removed from the Queue.

Parameters
pbuffpointer to a buffer, where the data should be stored
psizeon call contains the size of pbuff, on return contains the size of returned data
Return values
E_SUCCESSif succesful
E_CLOSEDif the queue is already empty AND closed
E_UNKNOWNin case of an error

Definition at line 258 of file CAQueue.cpp.

259  {
260  if(pbuff==NULL||psize==NULL)
261  return E_UNKNOWN;
262  if(*psize==0)
263  return E_SUCCESS;
264  m_pcsQueue->lock();
265  UINT32 space=*psize;
266  *psize=0;
267  if(m_Queue==NULL)
268  {
269  SINT32 ret=E_SUCCESS;
270  if(m_bClosed)
271  ret=E_CLOSED;
272  m_pcsQueue->unlock();
273  return ret;
274  }
275  QUEUE* tmpQueue=(QUEUE*)m_Queue;
276  while(space>=tmpQueue->size)
277  {
278  memcpy(pbuff,tmpQueue->pBuff+tmpQueue->index,tmpQueue->size);
279  *psize+=tmpQueue->size;
280  pbuff+=tmpQueue->size;
281  space-=tmpQueue->size;
282  tmpQueue=tmpQueue->next;
283  if(tmpQueue==NULL)
284  {
285  m_pcsQueue->unlock();
286  return E_SUCCESS;
287  }
288  }
289  memcpy(pbuff,tmpQueue->pBuff+tmpQueue->index,space);
290  *psize+=space;
291  m_pcsQueue->unlock();
292  return E_SUCCESS;
293  }

References E_CLOSED, E_SUCCESS, E_UNKNOWN, _t_queue::index, CAMutex::lock(), m_bClosed, m_pcsQueue, m_Queue, _t_queue::next, _t_queue::pBuff, _t_queue::size, and CAMutex::unlock().

Referenced by MemFormatTarget::dumpMem(), CALastMixA::loop(), and CAChain::sendUpstreamDataInternal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove()

SINT32 CAQueue::remove ( UINT32 psize)

Removes data from the Queue.

Parameters
psizeon call contains the size of data to remove, on return contains the size of removed data
Return values
E_SUCCESSif succesful
E_UNKNOWNin case of an error

Definition at line 302 of file CAQueue.cpp.

303  {
304  if(m_Queue==NULL||psize==NULL)
305  return E_UNKNOWN;
306  if(*psize==0)
307  return E_SUCCESS;
308  m_pcsQueue->lock();
309  UINT32 space=*psize;
310  *psize=0;
311  while(space>=m_Queue->size)
312  {
313  *psize+=m_Queue->size;
314  space-=m_Queue->size;
316  QUEUE* tmp=(QUEUE*)m_Queue;
318 // tmp->next=m_pHeap;
319 // m_pHeap=tmp;
320  delete[] tmp->pBuff;
321  tmp->pBuff = NULL;
322  delete tmp;
323  if(m_Queue==NULL)
324  {
325  m_pcsQueue->unlock();
326  return E_SUCCESS;
327  }
328  }
329  if(space>0)
330  {
331  *psize+=space;
332  m_Queue->size-=space;
333  m_nQueueSize-=space;
334  m_Queue->index+=space;
335  //memmove(m_Queue->pBuff,m_Queue->pBuff+space,m_Queue->size);
336  }
337  m_pcsQueue->unlock();
338  return E_SUCCESS;
339  }

References E_SUCCESS, E_UNKNOWN, _t_queue::index, CAMutex::lock(), m_nQueueSize, m_pcsQueue, m_Queue, _t_queue::next, _t_queue::pBuff, _t_queue::size, and CAMutex::unlock().

Referenced by CALastMixA::loop(), and CAChain::sendUpstreamDataInternal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test()

SINT32 CAQueue::test ( )
static

Method to test the Queue.

Return values
E_SUCCESS,ifQueue implementation seams to be ok

Definition at line 437 of file CAQueue.cpp.

438  {
439  CAQueue* pQueue=new CAQueue(1000);
440  #define TEST_SIZE 1000000
441  UINT8* source=new UINT8[TEST_SIZE];
442  UINT8* target=new UINT8[TEST_SIZE];
443  getRandom(source,TEST_SIZE);
444  UINT32 count=0;
445  UINT32 aktSize;
446 
447  srand((unsigned)time( NULL ));
448 
449  //Single Thread.....
450  //adding
451 
452  while(TEST_SIZE-count>10000)
453  {
454  aktSize=rand();
455  aktSize%=0xFFFF;
456  aktSize%=(TEST_SIZE-count);
457  if(pQueue->add(source+count,aktSize)!=E_SUCCESS)
458  return E_UNKNOWN;
459  count+=aktSize;
460  if(pQueue->getSize()!=count)
461  return E_UNKNOWN;
462  }
463  if(pQueue->add(source+count,TEST_SIZE-count)!=E_SUCCESS)
464  return E_UNKNOWN;
465  if(pQueue->getSize()!=TEST_SIZE)
466  return E_UNKNOWN;
467 
468  //getting
469  count=0;
470  while(!pQueue->isEmpty())
471  {
472  aktSize=rand();
473  aktSize%=0xFFFF;
474  if(pQueue->get(target+count,&aktSize)!=E_SUCCESS)
475  return E_UNKNOWN;
476  count+=aktSize;
477  }
478  if(count!=TEST_SIZE)
479  return E_UNKNOWN;
480  if(memcmp(source,target,TEST_SIZE)!=0)
481  return E_UNKNOWN;
482 
483  //Multiple Threads....
484  CAThread* pthreadProducer=new CAThread((UINT8*)"Queue Producer Thread");
485  CAThread* pthreadConsumer=new CAThread((UINT8*)"Queue Consumer Thread");
486  pthreadProducer->setMainLoop(producer);
487  pthreadConsumer->setMainLoop(consumer);
488  struct __queue_test t1,t2;
489  t1.buff=source;
490  t2.buff=target;
491  t2.len=t1.len=TEST_SIZE;
492  t2.pQueue=t1.pQueue=pQueue;
493  pthreadProducer->start(&t1);
494  pthreadConsumer->start(&t2);
495  pthreadProducer->join();
496  pthreadConsumer->join();
497  delete pthreadProducer;
498  pthreadProducer = NULL;
499  delete pthreadConsumer;
500  pthreadConsumer = NULL;
501  delete pQueue;
502  pQueue = NULL;
503  if(memcmp(source,target,TEST_SIZE)!=0)
504  return E_UNKNOWN;
505 
506  delete []source;
507  source = NULL;
508  delete []target;
509  target = NULL;
510  return E_SUCCESS;
511  }
THREAD_RETURN consumer(void *param)
Definition: CAQueue.cpp:411
#define TEST_SIZE
THREAD_RETURN producer(void *param)
Definition: CAQueue.cpp:388
SINT32 getRandom(UINT32 *val)
Gets 32 random bits.
Definition: CAUtil.cpp:346
This is a simple FIFO-Queue.
Definition: CAQueue.hpp:50
SINT32 add(const void *buff, UINT32 size)
Adds data to the Queue.
Definition: CAQueue.cpp:76
CAQueue(UINT32 expectedElementSize=0)
Give the size of the amount of data what you will add in one step.
Definition: CAQueue.hpp:57
UINT32 getSize()
Returns the size of stored data in byte.
Definition: CAQueue.hpp:101
bool isEmpty()
Returns true, if the Queue is empty.
Definition: CAQueue.hpp:125
SINT32 start(void *param, bool bDaemon=false, bool bSilent=false)
Starts the execution of the main function of this thread.
Definition: CAThread.cpp:115
SINT32 setMainLoop(THREAD_MAIN_TYP fnc)
Sets the main function which will be executed within this thread.
Definition: CAThread.hpp:148
SINT32 join()
Waits for the main function to finish execution.
Definition: CAThread.cpp:187
CAQueue * pQueue
Definition: CAQueue.cpp:343
UINT8 * buff
Definition: CAQueue.cpp:344

References add(), __queue_test::buff, CAQueue(), consumer(), E_SUCCESS, E_UNKNOWN, get(), getRandom(), getSize(), isEmpty(), CAThread::join(), __queue_test::len, __queue_test::pQueue, producer(), CAThread::setMainLoop(), CAThread::start(), and TEST_SIZE.

Here is the call graph for this function:

Member Data Documentation

◆ m_bClosed

volatile bool CAQueue::m_bClosed
private

Definition at line 155 of file CAQueue.hpp.

Referenced by add(), CAQueue(), close(), get(), getOrWait(), isClosed(), and peek().

◆ m_lastElem

volatile QUEUE* CAQueue::m_lastElem
private

Definition at line 153 of file CAQueue.hpp.

Referenced by add(), CAQueue(), and clean().

◆ m_nExpectedElementSize

UINT32 CAQueue::m_nExpectedElementSize
private

Definition at line 156 of file CAQueue.hpp.

Referenced by CAQueue().

◆ m_nQueueSize

volatile UINT32 CAQueue::m_nQueueSize
private

Definition at line 154 of file CAQueue.hpp.

Referenced by add(), CAQueue(), clean(), get(), getSize(), getSizeLookFree(), and remove().

◆ m_pconvarSize

CAConditionVariable* CAQueue::m_pconvarSize
private

Definition at line 159 of file CAQueue.hpp.

Referenced by add(), CAQueue(), close(), getOrWait(), and ~CAQueue().

◆ m_pcsQueue

CAMutex* CAQueue::m_pcsQueue
private

Definition at line 158 of file CAQueue.hpp.

Referenced by add(), CAQueue(), clean(), close(), get(), getSize(), peek(), remove(), and ~CAQueue().

◆ m_Queue

volatile QUEUE* CAQueue::m_Queue
private

Definition at line 152 of file CAQueue.hpp.

Referenced by add(), CAQueue(), clean(), close(), get(), getOrWait(), isEmpty(), peek(), and remove().


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