vdr 2.7.3
|
#include <thread.h>
Public Member Functions | |
cThread (const char *Description=NULL, bool LowPriority=false) | |
virtual | ~cThread () |
void | SetDescription (const char *Description,...) __attribute__((format(printf |
void bool | Start (void) |
bool | Active (void) |
Static Public Member Functions | |
static tThreadId | ThreadId (void) |
static tThreadId | IsMainThread (void) |
static void | SetMainThreadId (void) |
Protected Member Functions | |
void | SetPriority (int Priority) |
void | SetIOPriority (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 |
bool | lowPriority |
Static Private Attributes | |
static tThreadId | mainThreadId = 0 |
Friends | |
class | cThreadLock |
cThread::cThread | ( | const char * | Description = NULL, |
bool | LowPriority = false ) |
Creates a new thread.
If Description is present, a log file entry will be made when the thread starts and stops (see SetDescription()). The Start() function must be called to actually start the thread. LowPriority can be set to true to make this thread run at a lower priority.
Definition at line 238 of file thread.c.
References active, childThreadId, childTid, description, lowPriority, running, and SetDescription().
Referenced by cCiAdapter::cCiAdapter(), cCuttingThread::cCuttingThread(), cDirCopier::cDirCopier(), cDvbPlayer::cDvbPlayer(), cDvbSubtitleConverter::cDvbSubtitleConverter(), cEpgDataReader::cEpgDataReader(), cEpgDataWriter::cEpgDataWriter(), cIndexFileGenerator::cIndexFileGenerator(), cKbdRemote::cKbdRemote(), cLircRemote::cLircRemote(), cNonBlockingFileReader::cNonBlockingFileReader(), cRcuRemote::cRcuRemote(), cRecorder::cRecorder(), cRecordingsHandler::cRecordingsHandler(), cRemoveDeletedRecordingsThread::cRemoveDeletedRecordingsThread(), cSectionHandler::cSectionHandler(), cSVDRPClientHandler::cSVDRPClientHandler(), cSVDRPServerHandler::cSVDRPServerHandler(), cVideoDirectoryScannerThread::cVideoDirectoryScannerThread(), and StartThread().
|
virtual |
Definition at line 249 of file thread.c.
References Cancel(), and description.
|
protectedpure 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 cCiAdapter, cCuttingThread, cDevice, cDirCopier, cDvbPlayer, cDvbSubtitleConverter, cDvbTuner, cEpgDataReader, cEpgDataWriter, cIndexFileGenerator, cKbdRemote, cLircDevRemote, cLircUsrRemote, cNonBlockingFileReader, cRcuRemote, cRecorder, cRecordingsHandler, cRemoveDeletedRecordingsThread, cSectionHandler, cSVDRPClientHandler, cSVDRPServerHandler, cTrueColorDemo, cTSBuffer, and cVideoDirectoryScannerThread.
Referenced by StartThread().
bool cThread::Active | ( | void | ) |
|
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 354 of file thread.c.
References Active(), active, childThreadId, childTid, description, esyslog, running, and cCondWait::SleepMs().
Referenced by cDvbPlayer::Activate(), cRecorder::Activate(), cDevice::Detach(), cTrueColorDemo::ProcessKey(), cCiAdapter::~cCiAdapter(), cCuttingThread::~cCuttingThread(), cDevice::~cDevice(), cDirCopier::~cDirCopier(), cDvbCiAdapter::~cDvbCiAdapter(), cDvbSubtitleConverter::~cDvbSubtitleConverter(), cDvbTuner::~cDvbTuner(), cIndexFileGenerator::~cIndexFileGenerator(), cKbdRemote::~cKbdRemote(), cLircRemote::~cLircRemote(), cNonBlockingFileReader::~cNonBlockingFileReader(), cRcuRemote::~cRcuRemote(), cRecordingsHandler::~cRecordingsHandler(), cSectionHandler::~cSectionHandler(), cSVDRPClientHandler::~cSVDRPClientHandler(), cSVDRPServerHandler::~cSVDRPServerHandler(), ~cThread(), cTrueColorDemo::~cTrueColorDemo(), cTSBuffer::~cTSBuffer(), and cVideoDirectoryScannerThread::~cVideoDirectoryScannerThread().
|
inlinestatic |
Definition at line 131 of file thread.h.
References IsMainThread(), mainThreadId, and ThreadId().
Referenced by cPlugin::CacheDirectory(), cPlugin::ConfigDirectory(), IsMainThread(), cSkins::Message(), cSkins::ProcessQueuedMessages(), cSkins::QueueMessage(), cPlugin::ResourceDirectory(), and cDvbPlayer::SetAudioTrack().
|
inlineprotected |
Definition at line 94 of file thread.h.
References mutex.
Referenced by cDevice::Action(), cNonBlockingFileReader::Action(), cSectionHandler::Action(), cSectionHandler::Add(), cSectionHandler::Attach(), cNonBlockingFileReader::Clear(), cSectionHandler::Del(), cSectionHandler::Detach(), cThreadLock::Lock(), cNonBlockingFileReader::Request(), cDvbSubtitleConverter::Reset(), cSectionHandler::SetChannel(), and cSectionHandler::SetStatus().
|
inlineprotected |
Returns false if a derived cThread object shall leave its Action() function.
Definition at line 101 of file thread.h.
References running.
Referenced by cCiAdapter::Action(), cCuttingThread::Action(), cDevice::Action(), cDirCopier::Action(), cDvbPlayer::Action(), cDvbSubtitleConverter::Action(), cDvbTuner::Action(), cIndexFileGenerator::Action(), cKbdRemote::Action(), cLircDevRemote::Action(), cLircUsrRemote::Action(), cNonBlockingFileReader::Action(), cRcuRemote::Action(), cRecorder::Action(), cRecordingsHandler::Action(), cSectionHandler::Action(), cSVDRPClientHandler::Action(), cSVDRPServerHandler::Action(), cTrueColorDemo::Action(), cTSBuffer::Action(), cDvbPlayer::Active(), cCuttingThread::ProcessSequence(), cRecorder::Receive(), and cVideoDirectoryScannerThread::ScanVideoDir().
void cThread::SetDescription | ( | const char * | Description, |
... ) |
Definition at line 267 of file thread.c.
References description, and cString::vsprintf().
Referenced by cDevice::cDevice(), cDvbCiAdapter::cDvbCiAdapter(), cDvbTuner::cDvbTuner(), cSectionHandler::cSectionHandler(), cThread(), and cTSBuffer::cTSBuffer().
|
protected |
|
static |
Definition at line 377 of file thread.c.
References esyslog, mainThreadId, and ThreadId().
Referenced by main().
|
protected |
bool cThread::Start | ( | void | ) |
Sets the description of this thread, which will be used when logging starting or stopping of the thread.
Make sure any important information is within the first 15 characters of Description, because only these may be displayed in thread listings (like 'htop', for instance). Actually starts the thread. If the thread is already running, nothing happens.
Definition at line 304 of file thread.c.
References active, childTid, cTimeMs::Elapsed(), LOG_ERROR, running, cCondWait::SleepMs(), StartThread(), THREAD_STOP_SLEEP, and THREAD_STOP_TIMEOUT.
Referenced by cTrueColorDemo::Action(), cDvbPlayer::Activate(), cRecorder::Activate(), cRecordingsHandler::Add(), cDevice::AttachReceiver(), cCuttingThread::cCuttingThread(), cDvbCiAdapter::cDvbCiAdapter(), cDvbSubtitleConverter::cDvbSubtitleConverter(), cDvbTuner::cDvbTuner(), cIndexFileGenerator::cIndexFileGenerator(), cKbdRemote::cKbdRemote(), cLircUsrRemote::cLircUsrRemote(), cNonBlockingFileReader::cNonBlockingFileReader(), cLircDevRemote::Connect(), cRcuRemote::cRcuRemote(), cSectionHandler::cSectionHandler(), cTSBuffer::cTSBuffer(), main(), cDevice::PlayPesPacket(), and cTrueColorDemo::Show().
|
staticprivate |
Definition at line 279 of file thread.c.
References Action(), active, childThreadId, cThread(), description, dsyslog, esyslog, lowPriority, running, SetIOPriority(), SetPriority(), and ThreadId().
Referenced by Start().
|
static |
Definition at line 372 of file thread.c.
Referenced by cIoThrottle::Activate(), cStateLockLog::Check(), cSkinQueuedMessage::cSkinQueuedMessage(), cRingBufferLinear::Get(), IsMainThread(), cRwLock::Lock(), cStateLock::Lock(), main(), cSkins::QueueMessage(), cIoThrottle::Release(), cStateLock::SetExplicitModify(), SetMainThreadId(), cStateLock::SetModified(), cStateLock::SetSyncStateKey(), StartThread(), cStateKey::StateChanged(), syslog_with_tid(), cRwLock::Unlock(), and cStateLock::Unlock().
|
inlineprotected |
Definition at line 95 of file thread.h.
References mutex.
Referenced by cDevice::Action(), cNonBlockingFileReader::Action(), cSectionHandler::Action(), cSectionHandler::Add(), cSectionHandler::Attach(), cNonBlockingFileReader::Clear(), cSectionHandler::Del(), cSectionHandler::Detach(), cNonBlockingFileReader::Request(), cDvbSubtitleConverter::Reset(), cSectionHandler::SetChannel(), and cSectionHandler::SetStatus().
|
friend |
|
private |
|
private |
Definition at line 85 of file thread.h.
Referenced by Cancel(), cThread(), and StartThread().
|
private |
|
private |
Definition at line 87 of file thread.h.
Referenced by Cancel(), cDevice::ClrAvailableTracks(), cThread(), cDevice::SetAvailableTrack(), SetDescription(), StartThread(), and ~cThread().
|
private |
Definition at line 88 of file thread.h.
Referenced by cThread(), and StartThread().
|
staticprivate |
Definition at line 89 of file thread.h.
Referenced by IsMainThread(), and SetMainThreadId().
|
private |
|
private |