29 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_MIDDLE_MIX
89 memcpy(newEntry->
pBuff,buff,size);
126 #ifdef QUEUE_SIZE_LOG
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);
150 if(pbuff==NULL||psize==NULL)
245 ret=
get(pbuff,psize);
260 if(pbuff==NULL||psize==NULL)
276 while(space>=tmpQueue->
size)
279 *psize+=tmpQueue->
size;
280 pbuff+=tmpQueue->
size;
281 space-=tmpQueue->
size;
282 tmpQueue=tmpQueue->
next;
289 memcpy(pbuff,tmpQueue->
pBuff+tmpQueue->
index,space);
394 while (pTest->
len>10)
403 burst = rand() % 10+1;
429 burst = rand() % 10 + 1;
433 }
while (pTest->
len>10);
440 #define TEST_SIZE 1000000
447 srand((
unsigned)time( NULL ));
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;
THREAD_RETURN consumer(void *param)
THREAD_RETURN producer(void *param)
SINT32 getRandom(UINT32 *val)
Gets 32 random bits.
SINT32 msSleep(UINT32 ms)
Sleeps ms milliseconds.
#define THREAD_RETURN_ERROR
#define THREAD_RETURN_SUCCESS
SINT32 signal()
Signals this object.
SINT32 wait()
Waits for a signal or for a timeout.
static SINT32 printMsg(UINT32 typ, const char *format,...)
Writes a given message to the log.
This is a simple FIFO-Queue.
CAConditionVariable * m_pconvarSize
SINT32 add(const void *buff, UINT32 size)
Adds data to the Queue.
static SINT32 test()
Method to test the Queue.
SINT32 clean()
Removes any stored data from the Queue.
volatile UINT32 m_nQueueSize
SINT32 getOrWait(UINT8 *pbuff, UINT32 *psize)
Gets data from the Queue or waits until some data is available, if the Queue is empty.
SINT32 get(UINT8 *pbuff, UINT32 *psize)
Gets up to psize number of bytes from the Queue.
SINT32 peek(UINT8 *pbuff, UINT32 *psize)
Peeks data from the Queue.
CAQueue(UINT32 expectedElementSize=0)
Give the size of the amount of data what you will add in one step.
SINT32 remove(UINT32 *psize)
Removes data from the Queue.
UINT32 getSize()
Returns the size of stored data in byte.
~CAQueue()
Deletes this Queue and all stored data.
volatile QUEUE * m_lastElem
bool isEmpty()
Returns true, if the Queue is empty.
SINT32 start(void *param, bool bDaemon=false, bool bSilent=false)
Starts the execution of the main function of this thread.
SINT32 setMainLoop(THREAD_MAIN_TYP fnc)
Sets the main function which will be executed within this thread.
SINT32 join()
Waits for the main function to finish execution.