Mixes for Privacy and Anonymity in the Internet
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes

This class could be used for creating a new thread. More...

List of all members.

Public Member Functions

 CAThread ()
 Creates a CAThread object but no actual thread.
 CAThread (const UINT8 *strName)
 Creates a CAThread object but no actual thread.
 ~CAThread ()
SINT32 setMainLoop (THREAD_MAIN_TYP fnc)
 Sets the main function which will be executed within this thread.
SINT32 start (void *param, bool bDaemon=false, bool bSilent=false)
 Starts the execution of the main function of this thread.
SINT32 join ()
 Waits for the main function to finish execution.
UINT8getName () const
UINT32 getID () const

Static Public Member Functions

static thread_id_t getSelfID ()

Private Attributes

THREAD_MAIN_TYP m_fncMainLoop
pthread_t * m_pThread
UINT8m_strName
UINT32 m_Id

Static Private Attributes

static UINT32 ms_LastId = 0

Detailed Description

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:

  THREAD_RETURN doSomeThing(void* param)
    {
      THREAD_RETURN_SUCCESS
    }

Now we can create the thread, set the main function, start the thread and wait for the thread to finish execution:

  CAThread* pThread=new CAThread();
  pThread->setMainLoop(doSomeThing);
  pThread->start(theParams);
  pThread->join();
  delete pThread;

Constructor & Destructor Documentation

Creates a CAThread object but no actual thread.

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.

Parameters:
strNamea name for this thread, useful mostly for debugging

References len, m_fncMainLoop, m_Id, m_pThread, m_strName, and ms_LastId.

References m_pThread, and m_strName.


Member Function Documentation

References m_Id.

References m_strName.

static thread_id_t CAThread::getSelfID ( ) [static]
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().

Parameters:
parama pointer which is used as argument to the main function
bDaemontrue, if this thread should be a deamon thread. A daemon thread is a dettached thread, which will not
bSilentif 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.
Return values:
E_SUCCESSif the thread could be started successfully
E_UNKNOWNotherwise

References bytes2hex(), E_SUCCESS, E_UNKNOWN, m_fncMainLoop, m_pThread, m_strName, and CAMsg::printMsg().

Referenced by CAAccountingSettleThread::CAAccountingSettleThread(), CAFirstMixChannelList::CAFirstMixChannelList(), CATempIPBlockList::CATempIPBlockList(), CAThreadPool::CAThreadPool(), CALastMix::init(), CAFirstMix::init(), CAFirstMix::initCountryStats(), CALastMixA::loop(), CAFirstMixA::loop(), CALastMixB::loop(), CAMiddleMix::loop(), CACmdLnOptions::reread(), CAInfoService::sendHelo(), CADatabase::start(), CAReplayDatabase::start(), CAInfoService::start(), CAReplayCtrlChannelMsgProc::startTimeStampPorpagation(), and CAQueue::test().


Member Data Documentation

Referenced by CAThread(), setMainLoop(), and start().

Referenced by CAThread(), and getID().

pthread_t* CAThread::m_pThread [private]

Referenced by CAThread(), join(), start(), and ~CAThread().

Referenced by CAThread(), getName(), join(), start(), and ~CAThread().

UINT32 CAThread::ms_LastId = 0 [static, private]

Referenced by CAThread().