cThread Class Reference

#include <thread.h>

Inheritance diagram for cThread:

Inheritance graph
[legend]
Collaboration diagram for cThread:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 cThread (const char *Description=NULL)
virtual ~cThread ()
void SetDescription (const char *Description,...) __attribute__((format(printf
void bool Start (void)
 Actually starts the thread.
bool Active (void)
 Checks whether the thread is still alive.

Static Public Member Functions

static bool EmergencyExit (bool Request=false)
static tThreadId ThreadId (void)
static tThreadId IsMainThread (void)
static void SetMainThreadId (void)

Protected Member Functions

void SetPriority (int Priority)
void Lock (void)
void Unlock (void)
virtual void Action (void)=0
bool Running (void)
void Cancel (int WaitSeconds=0)

Static Private Member Functions

static void * StartThread (cThread *Thread)

Private Attributes

bool active
bool running
pthread_t childTid
tThreadId childThreadId
cMutex mutex
char * description

Static Private Attributes

static tThreadId mainThreadId = 0
static bool emergencyExitRequested = false

Friends

class cThreadLock


Detailed Description

Definition at line 77 of file thread.h.


Constructor & Destructor Documentation

cThread::cThread ( const char *  Description = NULL  ) 

Creates a new thread. If Description is present, a log file entry will be made when the thread starts and stops. The Start() function must be called to actually start the thread.

Definition at line 205 of file thread.c.

References active, childThreadId, childTid, description, running, and SetDescription().

Here is the call graph for this function:

cThread::~cThread (  )  [virtual]

Definition at line 215 of file thread.c.

References Cancel(), and description.

Here is the call graph for this function:


Member Function Documentation

void * cThread::StartThread ( cThread Thread  )  [static, private]

Definition at line 239 of file thread.c.

References Action(), active, childThreadId, description, dsyslog, running, and ThreadId().

Referenced by Start().

Here is the call graph for this function:

void cThread::SetPriority ( int  Priority  )  [protected]

Definition at line 221 of file thread.c.

References LOG_ERROR.

Referenced by cSectionHandler::Action().

void cThread::Lock ( void   )  [inline, protected]

Definition at line 91 of file thread.h.

References cMutex::Lock(), and mutex.

Referenced by cSectionHandler::Action(), cNonBlockingFileReader::Action(), cDevice::Action(), cSectionHandler::Add(), cSectionHandler::Attach(), cDevice::AttachReceiver(), cNonBlockingFileReader::Clear(), cSectionHandler::Del(), cSectionHandler::Detach(), cDevice::Detach(), cThreadLock::Lock(), cRecordings::Refresh(), cRecordings::ScanVideoDir(), cSectionHandler::SetChannel(), and cSectionHandler::SetStatus().

Here is the call graph for this function:

void cThread::Unlock ( void   )  [inline, protected]

Definition at line 92 of file thread.h.

References mutex, and cMutex::Unlock().

Referenced by cSectionHandler::Action(), cNonBlockingFileReader::Action(), cDevice::Action(), cSectionHandler::Add(), cSectionHandler::Attach(), cDevice::AttachReceiver(), cNonBlockingFileReader::Clear(), cSectionHandler::Del(), cSectionHandler::Detach(), cDevice::Detach(), cRecordings::Refresh(), cRecordings::ScanVideoDir(), cSectionHandler::SetChannel(), cSectionHandler::SetStatus(), and cThreadLock::~cThreadLock().

Here is the call graph for this function:

virtual void cThread::Action ( void   )  [protected, pure virtual]

A derived cThread class must implement the code it wants to execute as a separate thread in this function. If this is a loop, it must check Running() repeatedly to see whether it's time to stop.

Implemented in cCuttingThread, cDevice, cTSBuffer, cDvbTuner, cNonBlockingFileReader, cDvbPlayer, cLircRemote, cRcuRemote, cFileWriter, cRecorder, cRemoveDeletedRecordingsThread, cRecordings, cKbdRemote, cSectionHandler, and cTransfer.

Referenced by StartThread().

bool cThread::Running ( void   )  [inline, protected]

Returns false if a derived cThread object shall leave its Action() function.

Definition at line 98 of file thread.h.

References running.

Referenced by cTransfer::Action(), cSectionHandler::Action(), cKbdRemote::Action(), cRecorder::Action(), cFileWriter::Action(), cRcuRemote::Action(), cLircRemote::Action(), cDvbPlayer::Action(), cNonBlockingFileReader::Action(), cDvbTuner::Action(), cTSBuffer::Action(), cDevice::Action(), cCuttingThread::Action(), cDvbPlayer::Active(), cDevice::AttachReceiver(), cTransfer::Receive(), cRecorder::Receive(), and cRecordings::ScanVideoDir().

void cThread::Cancel ( int  WaitSeconds = 0  )  [protected]

Cancels the thread by first setting 'running' to false, so that the Action() loop can finish in an orderly fashion and then waiting up to WaitSeconds seconds for the thread to actually end. If the thread doesn't end by itself, it is killed. If WaitSeconds is -1, only 'running' is set to false and Cancel() returns immediately, without killing the thread.

Definition at line 293 of file thread.c.

References Active(), active, childThreadId, childTid, description, esyslog, running, and cCondWait::SleepMs().

Referenced by cTransfer::Activate(), cRecorder::Activate(), cDvbPlayer::Activate(), cDevice::Detach(), cCuttingThread::~cCuttingThread(), cDvbTuner::~cDvbTuner(), cFileWriter::~cFileWriter(), cKbdRemote::~cKbdRemote(), cLircRemote::~cLircRemote(), cNonBlockingFileReader::~cNonBlockingFileReader(), cRcuRemote::~cRcuRemote(), cRecordings::~cRecordings(), cSectionHandler::~cSectionHandler(), ~cThread(), and cTSBuffer::~cTSBuffer().

Here is the call graph for this function:

void cThread::SetDescription ( const char *  Description,
  ... 
)

Definition at line 227 of file thread.c.

References description.

Referenced by cDevice::cDevice(), cDvbTuner::cDvbTuner(), cThread(), and cTSBuffer::cTSBuffer().

bool cThread::Start ( void   ) 

Actually starts the thread.

Definition at line 252 of file thread.c.

References active, childTid, LOG_ERROR, running, and StartThread().

Referenced by cTransfer::Activate(), cRecorder::Activate(), cDvbPlayer::Activate(), cDevice::AttachReceiver(), cCuttingThread::cCuttingThread(), cDvbTuner::cDvbTuner(), cKbdRemote::cKbdRemote(), cLircRemote::cLircRemote(), cNonBlockingFileReader::cNonBlockingFileReader(), cRcuRemote::cRcuRemote(), cSectionHandler::cSectionHandler(), cTSBuffer::cTSBuffer(), cDevice::PlayPesPacket(), RemoveDeletedRecordings(), and cRecordings::Update().

Here is the call graph for this function:

bool cThread::Active ( void   ) 

Checks whether the thread is still alive.

Reimplemented in cDvbPlayer.

Definition at line 268 of file thread.c.

References active, childTid, LOG_ERROR, and running.

Referenced by cCutter::Active(), Cancel(), RemoveDeletedRecordings(), and cCutter::Stop().

bool cThread::EmergencyExit ( bool  Request = false  )  [static]

Definition at line 311 of file thread.c.

References emergencyExitRequested, and esyslog.

Referenced by cFileWriter::Action(), main(), cRemux::Put(), cMenuSetup::Restart(), and cRecordControls::Start().

tThreadId cThread::ThreadId ( void   )  [static]

Definition at line 319 of file thread.c.

Referenced by cSkinQueuedMessage::cSkinQueuedMessage(), cRingBufferLinear::Get(), IsMainThread(), main(), cSkins::QueueMessage(), SetMainThreadId(), StartThread(), and syslog_with_tid().

static tThreadId cThread::IsMainThread ( void   )  [inline, static]

Definition at line 122 of file thread.h.

References mainThreadId, and ThreadId().

Referenced by cPlugin::ConfigDirectory(), cSkins::ProcessQueuedMessages(), and cSkins::QueueMessage().

Here is the call graph for this function:

void cThread::SetMainThreadId ( void   )  [static]

Definition at line 324 of file thread.c.

References esyslog, mainThreadId, and ThreadId().

Referenced by main().

Here is the call graph for this function:


Friends And Related Function Documentation

friend class cThreadLock [friend]

Definition at line 78 of file thread.h.


Member Data Documentation

bool cThread::active [private]

Definition at line 80 of file thread.h.

Referenced by Active(), Cancel(), cThread(), Start(), and StartThread().

bool cThread::running [private]

Definition at line 81 of file thread.h.

Referenced by Active(), Cancel(), cThread(), Running(), Start(), and StartThread().

pthread_t cThread::childTid [private]

Definition at line 82 of file thread.h.

Referenced by Active(), Cancel(), cThread(), and Start().

tThreadId cThread::childThreadId [private]

Definition at line 83 of file thread.h.

Referenced by Cancel(), cThread(), and StartThread().

cMutex cThread::mutex [private]

Reimplemented in cDvbTuner.

Definition at line 84 of file thread.h.

Referenced by Lock(), and Unlock().

char* cThread::description [private]

Definition at line 85 of file thread.h.

Referenced by Cancel(), cDevice::ClrAvailableTracks(), cThread(), cDevice::SetAvailableTrack(), SetDescription(), StartThread(), and ~cThread().

tThreadId cThread::mainThreadId = 0 [static, private]

Definition at line 86 of file thread.h.

Referenced by IsMainThread(), and SetMainThreadId().

bool cThread::emergencyExitRequested = false [static, private]

Definition at line 87 of file thread.h.

Referenced by EmergencyExit().


The documentation for this class was generated from the following files:
Generated on Tue Nov 6 20:30:38 2007 for VDR by  doxygen 1.5.3-20071008