Mixe for Privacy and Anonymity in the Internet
Classes | Macros | Functions
CAQueue.cpp File Reference
#include "StdAfx.h"
#include "CAQueue.hpp"
#include "CAMsg.hpp"
#include "CAUtil.hpp"
#include "CAThread.hpp"
Include dependency graph for CAQueue.cpp:

Go to the source code of this file.

Classes

struct  __queue_test
 

Macros

#define TEST_SIZE   1000000
 

Functions

THREAD_RETURN producer (void *param)
 
THREAD_RETURN consumer (void *param)
 

Macro Definition Documentation

◆ TEST_SIZE

#define TEST_SIZE   1000000

Function Documentation

◆ consumer()

THREAD_RETURN consumer ( void *  param)

Definition at line 411 of file CAQueue.cpp.

412  {
413  struct __queue_test* pTest = (struct __queue_test *)param;
414  UINT32 aktSize=992;
415  UINT8 buff[992];
416  UINT8 b = 0;
417  UINT32 burst=1;
418  do
419  {
420  aktSize = 992;
421  if (pTest->pQueue->getOrWait(buff, &aktSize) != E_SUCCESS)
423  if (buff[0]!=b)
425  b++;
426  burst--;
427  if (burst == 0)
428  {
429  burst = rand() % 10 + 1;
430  msSleep(rand() % 100);
431 
432  }
433  } while (pTest->len>10);
435  }
SINT32 msSleep(UINT32 ms)
Sleeps ms milliseconds.
Definition: CAUtil.cpp:406
#define THREAD_RETURN_ERROR
Definition: StdAfx.h:541
#define THREAD_RETURN_SUCCESS
Definition: StdAfx.h:542
unsigned char UINT8
Definition: basetypedefs.h:135
unsigned int UINT32
Definition: basetypedefs.h:131
SINT32 getOrWait(UINT8 *pbuff, UINT32 *psize)
Gets data from the Queue or waits until some data is available, if the Queue is empty.
Definition: CAQueue.cpp:209
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2
SINT32 len
Definition: CAQueue.cpp:345
CAQueue * pQueue
Definition: CAQueue.cpp:343
UINT8 * buff
Definition: CAQueue.cpp:344

References __queue_test::buff, E_SUCCESS, CAQueue::getOrWait(), __queue_test::len, msSleep(), __queue_test::pQueue, THREAD_RETURN_ERROR, and THREAD_RETURN_SUCCESS.

Referenced by CAQueue::test().

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

◆ producer()

THREAD_RETURN producer ( void *  param)

Definition at line 388 of file CAQueue.cpp.

389  {
390  struct __queue_test* pTest = (struct __queue_test *)param;
391  UINT8 buff[992];
392  UINT8 b = 0;
393  UINT32 burst=1;
394  while (pTest->len>10)
395  {
396  buff[0] = b;
397  b++;
398  if (pTest->pQueue->add(buff, 992) != E_SUCCESS)
400  burst--;
401  if (burst == 0)
402  {
403  burst = rand() % 10+1;
404  msSleep(rand() % 100);
405 
406  }
407  }
409  }
SINT32 add(const void *buff, UINT32 size)
Adds data to the Queue.
Definition: CAQueue.cpp:76

References CAQueue::add(), __queue_test::buff, E_SUCCESS, __queue_test::len, msSleep(), __queue_test::pQueue, THREAD_RETURN_ERROR, and THREAD_RETURN_SUCCESS.

Referenced by CAQueue::test().

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