|
reSIProcate
SIP stack, Dialog Usage Manager and related libraries
|
A wrapper class to create and spawn a thread. More...
#include <ThreadIf.hxx>
Public Types | |
| typedef std::thread::id | Id |
| typedef pthread_key_t | TlsKey |
| typedef void | TlsDestructor(void *) |
Public Member Functions | |
| ThreadIf () | |
| virtual | ~ThreadIf () |
| virtual void | run () |
| void | join () |
| void | detach () |
| virtual void | shutdown () |
| virtual bool | waitForShutdown (int ms) const |
| bool | isShutdown () const |
| virtual void | thread ()=0 |
Static Public Member Functions | |
| static Id | selfId () |
| static int | tlsKeyCreate (TlsKey &key, TlsDestructor *destructor) |
| This function follows pthread_key_create() signature. | |
| static int | tlsKeyDelete (TlsKey key) |
| This function follows pthread_key_delete() signature. | |
| static int | tlsSetValue (TlsKey key, const void *val) |
| This function follows pthread_setspecific() signature. | |
| static void * | tlsGetValue (TlsKey key) |
| This function follows pthread_getspecific() signature. | |
Protected Attributes | |
| std::shared_ptr< std::thread > | mThreadObj |
| Id | mId |
| bool | mShutdown |
| Mutex | mShutdownMutex |
| Condition | mShutdownCondition |
A wrapper class to create and spawn a thread.
It is a base class. ThreadIf::thread() is a pure virtual method .
To use this class, derive from it and override the thread() method. To start the thread, call the run() method. The code in thread() will run in a separate thread.
Call shutdown() from the constructing thread to shut down the code. This will set the bool shutdown_ to true. The code in thread() should react properly to shutdown_ being set, by returning. Call join() to join the code.
Sample:
Definition at line 53 of file ThreadIf.hxx.
| typedef std::thread::id resip::ThreadIf::Id |
Definition at line 79 of file ThreadIf.hxx.
| typedef void resip::ThreadIf::TlsDestructor(void *) |
Definition at line 87 of file ThreadIf.hxx.
| typedef pthread_key_t resip::ThreadIf::TlsKey |
Definition at line 85 of file ThreadIf.hxx.
| ThreadIf::ThreadIf | ( | ) |
Definition at line 59 of file ThreadIf.cxx.
|
virtual |
Definition at line 68 of file ThreadIf.cxx.
| void ThreadIf::detach | ( | ) |
Definition at line 116 of file ThreadIf.cxx.
| bool ThreadIf::isShutdown | ( | ) | const |
Definition at line 212 of file ThreadIf.cxx.
| void ThreadIf::join | ( | ) |
Definition at line 92 of file ThreadIf.cxx.
|
virtual |
Definition at line 75 of file ThreadIf.cxx.
|
static |
Definition at line 124 of file ThreadIf.cxx.
|
virtual |
Reimplemented in repro::RegSyncClient, resip::EventStackThread, resip::InterruptableStackThread, recon::GstMediaStackAdapter, reTurn::UdpEchoServer, and resip::ProtonThreadBase.
Definition at line 190 of file ThreadIf.cxx.
|
pure virtual |
Implemented in flowmanager::IOServiceThread, repro::Proxy, repro::RegSyncClient, repro::WebAdminThread, resip::DumThread, mohparkserver::WebAdminThread, resip::EventStackThread, resip::InterruptableStackThread, resip::StackThread, resip::TransactionControllerThread, resip::TransportSelectorThread, resip::TransportThread, resip::WorkerThread, resip::DnsThread, reTurn::UdpEchoServer, and resip::ProtonThreadBase.
|
static |
This function follows pthread_getspecific() signature.
Definition at line 179 of file ThreadIf.cxx.
|
static |
This function follows pthread_key_create() signature.
Definition at line 130 of file ThreadIf.cxx.
|
static |
This function follows pthread_key_delete() signature.
Definition at line 150 of file ThreadIf.cxx.
|
static |
This function follows pthread_setspecific() signature.
Definition at line 169 of file ThreadIf.cxx.
|
virtual |
Definition at line 201 of file ThreadIf.cxx.
|
protected |
Definition at line 118 of file ThreadIf.hxx.
|
protected |
Definition at line 120 of file ThreadIf.hxx.
|
mutableprotected |
Definition at line 122 of file ThreadIf.hxx.
|
mutableprotected |
Definition at line 121 of file ThreadIf.hxx.
|
protected |
Definition at line 105 of file ThreadIf.hxx.