|
RTP Audio System
2.0.0
|
#include <thread.h>
Public Member Functions | |
| Thread (const char *name="Thread", const cardinal flags=TF_CancelDeferred) | |
| virtual | ~Thread () |
| bool | running () const |
| pid_t | getPID () const |
| virtual bool | start (const char *name=NULL) |
| virtual void * | stop () |
| void * | join () |
| virtual void | cancel () |
Static Public Member Functions | |
| static card64 | delay (const card64 delayTimeout, const bool interruptable=false) |
| static cardinal | setCancelState (const cardinal state) |
Static Public Attributes | |
| static const cardinal | TF_CancelAsynchronous = 0 |
| static const cardinal | TF_CancelDeferred = (1 << 0) |
| static const cardinal | TCS_CancelEnabled = PTHREAD_CANCEL_ENABLE |
| static const cardinal | TCS_CancelDisabled = PTHREAD_CANCEL_DISABLE |
| static const cardinal | TCS_CancelDeferred = PTHREAD_CANCEL_DEFERRED |
Protected Member Functions | |
| virtual void | testCancel () |
| virtual void | run ()=0 |
Static Protected Member Functions | |
| static void | exit (void *result=NULL) |
| static void | yield () |
Protected Attributes | |
| pthread_t | PThread |
| pid_t | PID |
Static Private Member Functions | |
| static void * | go (void *argument) |
Private Attributes | |
| cardinal | Flags |
| pthread_mutex_t | StartupMutex |
| pthread_cond_t | StartupCondition |
This abstract class realizes threads based on Linux's pthreads. The user of this class has to implement run(). Synchronization is implemented by inheriting Synchronizable. IMPORTANT: Do *not* use Thread methods within async signal handlers. This may cause deadlocks. See PThread's pthread_mutex_lock man-page, section "Async Signal Safety" for more information!
| Thread::Thread | ( | const char * | name = "Thread", |
| const cardinal | flags = TF_CancelDeferred |
||
| ) |
| Thread::~Thread | ( | ) | [virtual] |
Destructor. The thread will be stopped (if running) and deleted.
| void Thread::cancel | ( | ) | [virtual] |
Cancel the thread.
Reimplemented in MultiTimerThread< Timers >.
| card64 Thread::delay | ( | const card64 | delayTimeout, |
| const bool | interruptable = false |
||
| ) | [static] |
Delay execution of current thread for a given timeout. This function uses nanosleep(), so no signals are affected.
| delayTime | Timeout in microseconds. |
| interruptable | true, if delay may be interrupted by signals; false otherwise. |
| static void Thread::exit | ( | void * | result = NULL | ) | [inline, static, protected] |
Exit current thread.
| result | Result to return. |
| pid_t Thread::getPID | ( | ) | const [inline] |
Get thread's PID.
| void * Thread::go | ( | void * | argument | ) | [static, private] |
| void * Thread::join | ( | ) |
Wait for the thread to be finished.
| virtual void Thread::run | ( | ) | [protected, pure virtual] |
The virtual run() method, which contains the thread's implementation. It has to be implemented by classes, which inherit Thread.
Implemented in TestReceiver, MediaServent, MultiTimerThread< Timers >, AudioDevice, RTPReceiver, RTCPReceiver, and VerificationClientThread.
| bool Thread::running | ( | ) | const [inline] |
Check, if the thread is running.
| static cardinal Thread::setCancelState | ( | const cardinal | state | ) | [inline, static] |
Enable or disable cancelability of calling thread. The previous state is returned. Important note: The result may include additional state information, depending on the operating system. This state can be restored by giving this complete information to a setCancelState() call.
| enabled | TCS_CancelEnable to enable cancellation; TCS_CancelDisable otherwise. |
| bool Thread::start | ( | const char * | name = NULL | ) | [virtual] |
Start the thread, if not already started.
| name | Thread name (NULL for default). |
| void * Thread::stop | ( | ) | [virtual] |
Stop the thread, if not already stopped. If the thread flag ThreadCancelAsynchronous is set, it will be stopped immediately. If the flag ThreadCancelDeferred is set, it will be stopped when a cancellation point is reached (-> see pthreads documentation). testCancel() is such a cancellation point.
Reimplemented in AbstractMediaServer, MultiTimerThread< Timers >, RTCPAbstractServer, and VerificationClientThread.
| void Thread::testCancel | ( | ) | [protected, virtual] |
Test for cancellation. If the thread received a cancel signal, it will be cancelled.
| static void Thread::yield | ( | ) | [inline, static, protected] |
Voluntarily move current thread to end of queue of threads waiting for CPU time (sched_yield() call). This will result in scheduling to next waiting thread, if there is any.
cardinal Thread::Flags [private] |
pid_t Thread::PID [protected] |
pthread_t Thread::PThread [protected] |
pthread_cond_t Thread::StartupCondition [private] |
pthread_mutex_t Thread::StartupMutex [private] |
const cardinal Thread::TCS_CancelDeferred = PTHREAD_CANCEL_DEFERRED [static] |
const cardinal Thread::TCS_CancelDisabled = PTHREAD_CANCEL_DISABLE [static] |
const cardinal Thread::TCS_CancelEnabled = PTHREAD_CANCEL_ENABLE [static] |
const cardinal Thread::TF_CancelAsynchronous = 0 [static] |
const cardinal Thread::TF_CancelDeferred = (1 << 0) [static] |