Mixe for Privacy and Anonymity in the Internet
|
#include <CAThread.hpp>
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:
Definition at line 114 of file CAThread.hpp.
CAThread::CAThread | ( | ) |
Creates a CAThread object but no actual thread.
Definition at line 54 of file CAThread.cpp.
References m_fncMainLoop, m_Id, m_pThread, m_strName, and ms_LastId.
CAThread::CAThread | ( | const UINT8 * | strName | ) |
Creates a CAThread object but no actual thread.
strName | a name for this thread, useful mostly for debugging |
Definition at line 70 of file CAThread.cpp.
References len, m_fncMainLoop, m_Id, m_pThread, m_strName, and ms_LastId.
|
inline |
|
inline |
Definition at line 196 of file CAThread.hpp.
References m_Id.
Referenced by CAThreadList::remove(), CAThreadList::removeAll(), CAThreadList::showAll(), and CAThreadList::waitAndRemoveAll().
|
inline |
Definition at line 191 of file CAThread.hpp.
References m_strName.
Referenced by CAThreadList::removeAll(), CAThreadList::showAll(), and CAThreadList::waitAndRemoveAll().
|
inlinestatic |
Definition at line 201 of file CAThread.hpp.
Referenced by CAAccountingDBInterface::checkOwner(), openssl_get_thread_id(), CAAccountingDBInterface::testAndResetOwner(), and CAAccountingDBInterface::testAndSetOwner().
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 |
Definition at line 187 of file CAThread.cpp.
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().
|
inline |
Sets the main function which will be executed within this thread.
fnc | the fuction to be executed |
E_SUCCESS |
Definition at line 148 of file CAThread.hpp.
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 |
Definition at line 115 of file CAThread.cpp.
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 |
Definition at line 223 of file CAThread.hpp.
Referenced by CAThread(), setMainLoop(), and start().
|
private |
Definition at line 230 of file CAThread.hpp.
Referenced by CAThread(), and getID().
|
private |
Definition at line 227 of file CAThread.hpp.
Referenced by CAThread(), join(), start(), and ~CAThread().
|
private |
Definition at line 229 of file CAThread.hpp.
Referenced by CAThread(), getName(), join(), start(), and ~CAThread().
|
staticprivate |
Definition at line 231 of file CAThread.hpp.
Referenced by CAThread().