Mixes for Privacy and Anonymity in the Internet
|
Public Member Functions | |
CAThread () | |
Creates a CAThread object but no actual thread. More... | |
CAThread (const UINT8 *strName) | |
Creates a CAThread object but no actual thread. More... | |
~CAThread () | |
SINT32 | setMainLoop (THREAD_MAIN_TYP fnc) |
Sets the main function which will be executed within this thread. More... | |
SINT32 | start (void *param, bool bDaemon=false, bool bSilent=false) |
Starts the execution of the main function of this thread. More... | |
SINT32 | join () |
Waits for the main function to finish execution. More... | |
UINT8 * | getName () const |
UINT32 | getID () const |
Static Public Member Functions | |
static thread_id_t | getSelfID () |
Private Attributes | |
THREAD_MAIN_TYP | m_fncMainLoop |
pthread_t * | m_pThread |
UINT8 * | m_strName |
UINT32 | m_Id |
Static Private Attributes | |
static UINT32 | ms_LastId =0 |
@ingroup threading This class could be used for creating a new thread. The function which should be executed within this thread could be set be using the setMainLoop() method.
Some example on using CAThread:
First one needs to define a function which should be executed within the thread:
Now we can create the thread, set the main function, start the thread and wait for the thread to finish execution:
CAThread::CAThread | ( | ) |
CAThread::CAThread | ( | const UINT8 * | strName | ) |
UINT32 CAThread::getID | ( | ) | const |
References m_Id.
Referenced by CAThreadList::remove(), CAThreadList::removeAll(), CAThreadList::showAll(), and CAThreadList::waitAndRemoveAll().
UINT8* CAThread::getName | ( | ) | const |
References m_strName.
Referenced by CAThreadList::removeAll(), CAThreadList::showAll(), and CAThreadList::waitAndRemoveAll().
|
static |
SINT32 CAThread::join | ( | ) |
Waits for the main function to finish execution.
A call of this method will block until the main function exits.
E_SUCCESS | if successful |
E_UNKNOWN | otherwise |
References E_SUCCESS, E_UNKNOWN, m_pThread, m_strName, and CAMsg::printMsg().
Referenced by CAFirstMix::clean(), CALastMix::clean(), CAFirstMix::deleteCountryStats(), CAThreadPool::destroy(), CAMiddleMix::loop(), CAFirstMixA::loop(), CALastMixA::loop(), CAFirstMixB::loop(), CALastMixB::loop(), CAFirstMixA::shutDown(), CADatabase::stop(), CAInfoService::stop(), CAReplayDatabase::stop(), CAReplayCtrlChannelMsgProc::stopTimeStampPorpagation(), CAQueue::test(), CAThreadList::waitAndRemoveAll(), CAAccountingSettleThread::~CAAccountingSettleThread(), CAFirstMixChannelList::~CAFirstMixChannelList(), and CATempIPBlockList::~CATempIPBlockList().
SINT32 CAThread::setMainLoop | ( | THREAD_MAIN_TYP | fnc | ) |
Sets the main function which will be executed within this thread.
fnc | the fuction to be executed |
E_SUCCESS |
References E_SUCCESS, and m_fncMainLoop.
Referenced by CACryptoBenchmark::benchmarkThread(), CAAccountingSettleThread::CAAccountingSettleThread(), CAFirstMixChannelList::CAFirstMixChannelList(), CATempIPBlockList::CATempIPBlockList(), CAThreadPool::CAThreadPool(), CACryptoBenchmark::doBenchmark(), CAFirstMix::init(), CAFirstMix::initCountryStats(), CAMiddleMix::loop(), CAFirstMixA::loop(), CALastMixA::loop(), CALastMixB::loop(), CACmdLnOptions::reread(), CAInfoService::sendHelo(), CADatabase::start(), CAInfoService::start(), CAReplayDatabase::start(), CAReplayCtrlChannelMsgProc::startTimeStampPorpagation(), and CAQueue::test().
SINT32 CAThread::start | ( | void * | param, |
bool | bDaemon = false , |
||
bool | bSilent = false |
||
) |
Starts the execution of the main function of this thread.
The main function could be set with setMainLoop().
param | a pointer which is used as argument to the main function |
bDaemon | true, if this thread should be a deamon thread. A daemon thread is a dettached thread, which will not |
bSilent | if true, no (log) messages about thats going on are produced. This is especially helpful to avoid any blocking on any mutex during a call to start(). preserve a join state. A daemon thread will automatically release resources which are associated with the thread. Normaly this is done by calling join(). The default value is false. |
E_SUCCESS | if the thread could be started successfully |
E_UNKNOWN | otherwise |
References bytes2hex(), E_SUCCESS, E_UNKNOWN, m_fncMainLoop, m_pThread, m_strName, and CAMsg::printMsg().
Referenced by CACryptoBenchmark::benchmarkThread(), CAAccountingSettleThread::CAAccountingSettleThread(), CAFirstMixChannelList::CAFirstMixChannelList(), CATempIPBlockList::CATempIPBlockList(), CAThreadPool::CAThreadPool(), CACryptoBenchmark::doBenchmark(), CAFirstMix::init(), CAFirstMix::initCountryStats(), CAMiddleMix::loop(), CAFirstMixA::loop(), CALastMixA::loop(), CALastMixB::loop(), CACmdLnOptions::reread(), CAInfoService::sendHelo(), CADatabase::start(), CAInfoService::start(), CAReplayDatabase::start(), CAReplayCtrlChannelMsgProc::startTimeStampPorpagation(), and CAQueue::test().
|
private |
Referenced by CAThread(), setMainLoop(), and start().
|
private |
Referenced by CAThread(), and getID().
|
private |
Referenced by CAThread(), join(), start(), and ~CAThread().
|
private |
Referenced by CAThread(), getName(), join(), start(), and ~CAThread().
|
staticprivate |
Referenced by CAThread().