vdr
1.7.27
|
#include <thread.h>
Public Member Functions | |
cThread (const char *Description=NULL) | |
virtual | ~cThread () |
void | SetDescription (const char *Description,...) __attribute__((format(printf |
void bool | Start (void) |
bool | Active (void) |
cThread (const char *Description=NULL) | |
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) |
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) |
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) |
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 |
Friends | |
class | cThreadLock |
Definition at line 77 of file include/vdr/thread.h.
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 207 of file thread.c.
References active, childThreadId, childTid, description, running, and SetDescription().
cThread::~cThread | ( | ) | [virtual] |
Definition at line 217 of file thread.c.
References Cancel(), and description.
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.
virtual cThread::~cThread | ( | ) | [virtual] |
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 cIndexFileGenerator, cTSBuffer, cTSBuffer, cDevice, cDevice, cDvbTuner, cDvbPlayer, cEpgDataReader, cEpgDataReader, cRecordings, cRecordings, cKbdRemote, cKbdRemote, cNonBlockingFileReader, cCiAdapter, cCiAdapter, cTrueColorDemo, cRemoveDeletedRecordingsThread, cDvbSubtitleConverter, cDvbSubtitleConverter, cRcuRemote, cCopyingThread, cRecorder, cSectionHandler, cRecorder, cSectionHandler, cCuttingThread, cLircRemote, and cLircRemote.
Referenced by StartThread().
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 cIndexFileGenerator, cTSBuffer, cTSBuffer, cDevice, cDevice, cDvbTuner, cDvbPlayer, cEpgDataReader, cEpgDataReader, cRecordings, cRecordings, cKbdRemote, cKbdRemote, cNonBlockingFileReader, cCiAdapter, cCiAdapter, cTrueColorDemo, cRemoveDeletedRecordingsThread, cDvbSubtitleConverter, cDvbSubtitleConverter, cRcuRemote, cCopyingThread, cRecorder, cSectionHandler, cRecorder, cSectionHandler, cCuttingThread, cLircRemote, and cLircRemote.
bool cThread::Active | ( | void | ) |
Checks whether the thread is still alive.
Reimplemented in cDvbPlayer.
Definition at line 293 of file thread.c.
References active, childTid, LOG_ERROR, and running.
Referenced by cFileTransfer::Active(), cCutter::Active(), Cancel(), GenerateIndex(), RemoveDeletedRecordings(), cFileTransfer::Stop(), and cCutter::Stop().
bool cThread::Active | ( | void | ) |
Checks whether the thread is still alive.
Reimplemented in cDvbPlayer.
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 318 of file thread.c.
References active, Active(), childThreadId, childTid, description, esyslog, running, and cCondWait::SleepMs().
Referenced by cRecorder::Activate(), cDvbPlayer::Activate(), cDevice::Detach(), cCiAdapter::~cCiAdapter(), cCopyingThread::~cCopyingThread(), cCuttingThread::~cCuttingThread(), cDvbCiAdapter::~cDvbCiAdapter(), cDvbSubtitleConverter::~cDvbSubtitleConverter(), cDvbTuner::~cDvbTuner(), cIndexFileGenerator::~cIndexFileGenerator(), cKbdRemote::~cKbdRemote(), cLircRemote::~cLircRemote(), cNonBlockingFileReader::~cNonBlockingFileReader(), cRcuRemote::~cRcuRemote(), cRecordings::~cRecordings(), cSectionHandler::~cSectionHandler(), ~cThread(), cTrueColorDemo::~cTrueColorDemo(), and cTSBuffer::~cTSBuffer().
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.
static tThreadId cThread::IsMainThread | ( | void | ) | [inline, static] |
Definition at line 122 of file include/vdr/thread.h.
References mainThreadId, and ThreadId().
Referenced by cPlugin::ConfigDirectory(), cSkins::Message(), cSkins::ProcessQueuedMessages(), and cSkins::QueueMessage().
static tThreadId cThread::IsMainThread | ( | void | ) | [inline, static] |
Definition at line 122 of file thread.h.
References mainThreadId, and ThreadId().
void cThread::Lock | ( | void | ) | [inline, protected] |
Definition at line 91 of file thread.h.
References cMutex::Lock(), and mutex.
void cThread::Lock | ( | void | ) | [inline, protected] |
Definition at line 91 of file include/vdr/thread.h.
References cMutex::Lock(), and mutex.
Referenced by cSectionHandler::Action(), cTrueColorDemo::Action(), cNonBlockingFileReader::Action(), cDevice::Action(), cSectionHandler::Add(), cSectionHandler::Attach(), cDevice::AttachReceiver(), cNonBlockingFileReader::Clear(), cSectionHandler::Del(), cSectionHandler::Detach(), cDevice::Detach(), cThreadLock::Lock(), cRecordings::Refresh(), cNonBlockingFileReader::Request(), cDvbSubtitleConverter::Reset(), cRecordings::ScanVideoDir(), cSectionHandler::SetChannel(), and cSectionHandler::SetStatus().
bool cThread::Running | ( | void | ) | [inline, protected] |
bool cThread::Running | ( | void | ) | [inline, protected] |
Returns false if a derived cThread object shall leave its Action() function.
Definition at line 98 of file include/vdr/thread.h.
References running.
Referenced by cLircRemote::Action(), cCuttingThread::Action(), cSectionHandler::Action(), cRecorder::Action(), cCopyingThread::Action(), cRcuRemote::Action(), cDvbSubtitleConverter::Action(), cTrueColorDemo::Action(), cCiAdapter::Action(), cNonBlockingFileReader::Action(), cKbdRemote::Action(), cDvbPlayer::Action(), cDvbTuner::Action(), cDevice::Action(), cTSBuffer::Action(), cIndexFileGenerator::Action(), cDvbPlayer::Active(), cRecorder::Receive(), and cRecordings::ScanVideoDir().
void cThread::SetDescription | ( | const char * | Description, |
... | |||
) |
Definition at line 235 of file thread.c.
References description, and cString::sprintf().
Referenced by cDevice::cDevice(), cDvbCiAdapter::cDvbCiAdapter(), cDvbTuner::cDvbTuner(), cThread(), and cTSBuffer::cTSBuffer().
void cThread::SetDescription | ( | const char * | Description, |
... | |||
) |
void cThread::SetIOPriority | ( | int | Priority | ) | [protected] |
void cThread::SetIOPriority | ( | int | Priority | ) | [protected] |
Definition at line 229 of file thread.c.
References LOG_ERROR.
Referenced by cCuttingThread::Action(), cCopyingThread::Action(), and cRemoveDeletedRecordingsThread::Action().
static void cThread::SetMainThreadId | ( | void | ) | [static] |
void cThread::SetMainThreadId | ( | void | ) | [static] |
Definition at line 341 of file thread.c.
References esyslog, mainThreadId, and ThreadId().
Referenced by main().
void cThread::SetPriority | ( | int | Priority | ) | [protected] |
void cThread::SetPriority | ( | int | Priority | ) | [protected] |
Definition at line 223 of file thread.c.
References LOG_ERROR.
Referenced by cCuttingThread::Action(), cSectionHandler::Action(), cCopyingThread::Action(), and cRemoveDeletedRecordingsThread::Action().
void bool cThread::Start | ( | void | ) |
Actually starts the thread.
If the thread is already running, nothing happens.
bool cThread::Start | ( | void | ) |
Actually starts the thread.
If the thread is already running, nothing happens.
Definition at line 268 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(), cRecorder::Activate(), cDvbPlayer::Activate(), cDevice::AttachReceiver(), cCopyingThread::cCopyingThread(), cCuttingThread::cCuttingThread(), cDvbCiAdapter::cDvbCiAdapter(), cDvbSubtitleConverter::cDvbSubtitleConverter(), cDvbTuner::cDvbTuner(), cIndexFileGenerator::cIndexFileGenerator(), cKbdRemote::cKbdRemote(), cLircRemote::cLircRemote(), cNonBlockingFileReader::cNonBlockingFileReader(), cRcuRemote::cRcuRemote(), cSectionHandler::cSectionHandler(), cTSBuffer::cTSBuffer(), main(), cDevice::PlayPesPacket(), RemoveDeletedRecordings(), cTrueColorDemo::Show(), and cRecordings::Update().
void * cThread::StartThread | ( | cThread * | Thread | ) | [static, private] |
Definition at line 247 of file thread.c.
References Action(), active, childThreadId, description, dsyslog, esyslog, running, and ThreadId().
Referenced by Start().
static void* cThread::StartThread | ( | cThread * | Thread | ) | [static, private] |
tThreadId cThread::ThreadId | ( | void | ) | [static] |
Definition at line 336 of file thread.c.
Referenced by cSkinQueuedMessage::cSkinQueuedMessage(), cRingBufferLinear::Get(), IsMainThread(), main(), cSkins::QueueMessage(), SetMainThreadId(), StartThread(), and syslog_with_tid().
static tThreadId cThread::ThreadId | ( | void | ) | [static] |
void cThread::Unlock | ( | void | ) | [inline, protected] |
Definition at line 92 of file thread.h.
References mutex, and cMutex::Unlock().
void cThread::Unlock | ( | void | ) | [inline, protected] |
Definition at line 92 of file include/vdr/thread.h.
References mutex, and cMutex::Unlock().
Referenced by cSectionHandler::Action(), cTrueColorDemo::Action(), cNonBlockingFileReader::Action(), cDevice::Action(), cSectionHandler::Add(), cSectionHandler::Attach(), cDevice::AttachReceiver(), cNonBlockingFileReader::Clear(), cSectionHandler::Del(), cSectionHandler::Detach(), cDevice::Detach(), cRecordings::Refresh(), cNonBlockingFileReader::Request(), cDvbSubtitleConverter::Reset(), cRecordings::ScanVideoDir(), cSectionHandler::SetChannel(), cSectionHandler::SetStatus(), and cThreadLock::~cThreadLock().
cThreadLock [friend] |
Definition at line 78 of file include/vdr/thread.h.
bool cThread::active [private] |
Definition at line 80 of file include/vdr/thread.h.
Referenced by Active(), Cancel(), cThread(), Start(), and StartThread().
tThreadId cThread::childThreadId [private] |
Definition at line 83 of file include/vdr/thread.h.
Referenced by Cancel(), cThread(), and StartThread().
pthread_t cThread::childTid [private] |
char * cThread::description [private] |
Definition at line 85 of file include/vdr/thread.h.
Referenced by Cancel(), cDevice::ClrAvailableTracks(), cThread(), cDevice::SetAvailableTrack(), SetDescription(), StartThread(), and ~cThread().
static tThreadId cThread::mainThreadId = 0 [static, private] |
Definition at line 86 of file include/vdr/thread.h.
Referenced by IsMainThread(), and SetMainThreadId().
cMutex cThread::mutex [private] |
Reimplemented in cDvbTuner.
Definition at line 84 of file include/vdr/thread.h.
bool cThread::running [private] |
Definition at line 81 of file include/vdr/thread.h.
Referenced by Active(), Cancel(), cThread(), Running(), Start(), and StartThread().