vdr 2.7.7
cThread Class Referenceabstract

#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

Detailed Description

Definition at line 79 of file thread.h.

Constructor & Destructor Documentation

◆ cThread()

◆ ~cThread()

cThread::~cThread ( )
virtual

Definition at line 250 of file thread.c.

References Cancel(), and description.

Member Function Documentation

◆ Action()

virtual void cThread::Action ( void )
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().

◆ Active()

bool cThread::Active ( void )

Checks whether the thread is still alive.

Definition at line 330 of file thread.c.

References active, childTid, LOG_ERROR, and running.

Referenced by Cancel(), and GenerateIndex().

◆ Cancel()

◆ IsMainThread()

◆ Lock()

◆ Running()

◆ SetDescription()

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

◆ SetIOPriority()

void cThread::SetIOPriority ( int Priority)
protected

Definition at line 262 of file thread.c.

References LOG_ERROR.

Referenced by StartThread().

◆ SetMainThreadId()

void cThread::SetMainThreadId ( void )
static

Definition at line 378 of file thread.c.

References esyslog, mainThreadId, and ThreadId().

Referenced by main().

◆ SetPriority()

void cThread::SetPriority ( int Priority)
protected

Definition at line 256 of file thread.c.

References LOG_ERROR.

Referenced by StartThread().

◆ Start()

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 305 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().

◆ StartThread()

void * cThread::StartThread ( cThread * Thread)
staticprivate

◆ ThreadId()

◆ Unlock()

◆ cThreadLock

friend class cThreadLock
friend

Definition at line 80 of file thread.h.

References cThreadLock.

Referenced by cThreadLock.

Member Data Documentation

◆ active

bool cThread::active
private

Definition at line 82 of file thread.h.

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

◆ childThreadId

tThreadId cThread::childThreadId
private

Definition at line 85 of file thread.h.

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

◆ childTid

pthread_t cThread::childTid
private

Definition at line 84 of file thread.h.

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

◆ description

char* cThread::description
private

◆ lowPriority

bool cThread::lowPriority
private

Definition at line 88 of file thread.h.

Referenced by cThread(), and StartThread().

◆ mainThreadId

tThreadId cThread::mainThreadId = 0
staticprivate

Definition at line 89 of file thread.h.

Referenced by IsMainThread(), and SetMainThreadId().

◆ mutex

cMutex cThread::mutex
private

Definition at line 86 of file thread.h.

Referenced by Lock(), and Unlock().

◆ running

bool cThread::running
private

Definition at line 83 of file thread.h.

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


The documentation for this class was generated from the following files: