Mixes for Privacy and Anonymity in the Internet
Public Member Functions | Private Attributes | Friends | List of all members
CAThreadPool Class Reference

This class bla bla. More...

Public Member Functions

 CAThreadPool (UINT32 num_worker_threads, UINT32 max_queue_size, bool b_do_not_block_when_full)
 
 ~CAThreadPool ()
 
SINT32 destroy (bool bWaitForFinish)
 
SINT32 addRequest (THREAD_MAIN_TYP, void *args)
 Adds a new request (task) to this threadpool. More...
 
UINT32 countRequests ()
 

Private Attributes

UINT32 m_NumThreads
 
UINT32 m_MaxQueueSize
 
bool m_bDoNotBlockWhenFull
 
CAThread ** m_parThreads
 
volatile UINT32 m_CurQueueSize
 
tpool_work_tm_pQueueHead
 
tpool_work_tm_pQueueTail
 
volatile bool m_bQueueClosed
 
volatile bool m_bShutdown
 
CAMutexm_pmutexQueue
 
CAConditionVariablem_pcondNotEmpty
 
CAConditionVariablem_pcondNotFull
 
CAConditionVariablem_pcondEmpty
 

Friends

THREAD_RETURN worker_thread_main_loop (void *args)
 

Detailed Description

This class bla bla.

Constructor & Destructor Documentation

◆ CAThreadPool()

CAThreadPool::CAThreadPool ( UINT32  num_worker_threads,
UINT32  max_queue_size,
bool  b_do_not_block_when_full 
)

◆ ~CAThreadPool()

CAThreadPool::~CAThreadPool ( )

References destroy().

Member Function Documentation

◆ addRequest()

SINT32 CAThreadPool::addRequest ( THREAD_MAIN_TYP  routine,
void *  args 
)

Adds a new request (task) to this threadpool.

Return values
E_SPACeif there was no more space in the waiting queue and we do not want to wait for an other request to finish
E_SUCCESSif this request was added to the working queue

References tpool_work::arg, CAConditionVariable::broadcast(), E_SPACE, E_SUCCESS, E_UNKNOWN, CAMutex::lock(), m_bDoNotBlockWhenFull, m_bQueueClosed, m_bShutdown, m_CurQueueSize, m_MaxQueueSize, m_pcondNotEmpty, m_pcondNotFull, m_pmutexQueue, m_pQueueHead, m_pQueueTail, tpool_work::next, CAMsg::printMsg(), tpool_work::routine, CAMutex::unlock(), and CAConditionVariable::wait().

Referenced by CALastMixA::loop().

◆ countRequests()

UINT32 CAThreadPool::countRequests ( )

References m_CurQueueSize.

◆ destroy()

SINT32 CAThreadPool::destroy ( bool  bWaitForFinish)

Friends And Related Function Documentation

◆ worker_thread_main_loop

THREAD_RETURN worker_thread_main_loop ( void *  args)
friend

Referenced by CAThreadPool().

Member Data Documentation

◆ m_bDoNotBlockWhenFull

bool CAThreadPool::m_bDoNotBlockWhenFull
private

Referenced by addRequest(), and CAThreadPool().

◆ m_bQueueClosed

volatile bool CAThreadPool::m_bQueueClosed
private

Referenced by addRequest(), CAThreadPool(), and destroy().

◆ m_bShutdown

volatile bool CAThreadPool::m_bShutdown
private

Referenced by addRequest(), CAThreadPool(), and destroy().

◆ m_CurQueueSize

volatile UINT32 CAThreadPool::m_CurQueueSize
private

◆ m_MaxQueueSize

UINT32 CAThreadPool::m_MaxQueueSize
private

Referenced by addRequest(), and CAThreadPool().

◆ m_NumThreads

UINT32 CAThreadPool::m_NumThreads
private

Referenced by CAThreadPool(), and destroy().

◆ m_parThreads

CAThread** CAThreadPool::m_parThreads
private

Referenced by CAThreadPool(), and destroy().

◆ m_pcondEmpty

CAConditionVariable* CAThreadPool::m_pcondEmpty
private

Referenced by CAThreadPool(), and destroy().

◆ m_pcondNotEmpty

CAConditionVariable* CAThreadPool::m_pcondNotEmpty
private

Referenced by addRequest(), CAThreadPool(), and destroy().

◆ m_pcondNotFull

CAConditionVariable* CAThreadPool::m_pcondNotFull
private

Referenced by addRequest(), CAThreadPool(), and destroy().

◆ m_pmutexQueue

CAMutex* CAThreadPool::m_pmutexQueue
private

Referenced by addRequest(), CAThreadPool(), and destroy().

◆ m_pQueueHead

tpool_work_t* CAThreadPool::m_pQueueHead
private

Referenced by addRequest(), CAThreadPool(), and destroy().

◆ m_pQueueTail

tpool_work_t* CAThreadPool::m_pQueueTail
private

Referenced by addRequest(), and CAThreadPool().