vdr 2.6.1
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
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)
 
 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)
 
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
 
bool lowPriority
 

Static Private Attributes

static tThreadId mainThreadId = 0
 

Friends

class cThreadLock
 

Detailed Description

Definition at line 79 of file include/vdr/thread.h.

Constructor & Destructor Documentation

◆ cThread() [1/2]

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

◆ ~cThread() [1/2]

cThread::~cThread ( )
virtual

Definition at line 249 of file thread.c.

References Cancel(), and description.

◆ cThread() [2/2]

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.

◆ ~cThread() [2/2]

virtual cThread::~cThread ( )
virtual

Member Function Documentation

◆ Action() [1/2]

virtual void cThread::Action ( void  )
protectedpure virtual

◆ Action() [2/2]

virtual void cThread::Action ( void  )
protectedpure virtual

◆ Active() [1/2]

bool cThread::Active ( void  )

◆ Active() [2/2]

bool cThread::Active ( void  )

Checks whether the thread is still alive.

◆ Cancel() [1/2]

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

◆ Cancel() [2/2]

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.

◆ IsMainThread() [1/2]

static tThreadId cThread::IsMainThread ( void  )
inlinestatic

◆ IsMainThread() [2/2]

static tThreadId cThread::IsMainThread ( void  )
inlinestatic

Definition at line 131 of file thread.h.

References mainThreadId, and ThreadId().

◆ Lock() [1/2]

void cThread::Lock ( void  )
inlineprotected

◆ Lock() [2/2]

void cThread::Lock ( void  )
inlineprotected

Definition at line 94 of file thread.h.

References cMutex::Lock(), and mutex.

◆ Running() [1/2]

bool cThread::Running ( void  )
inlineprotected

◆ Running() [2/2]

bool cThread::Running ( void  )
inlineprotected

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

Definition at line 101 of file thread.h.

References running.

◆ SetDescription() [1/2]

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

◆ SetDescription() [2/2]

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

◆ SetIOPriority() [1/2]

void cThread::SetIOPriority ( int  Priority)
protected

Definition at line 261 of file thread.c.

References LOG_ERROR.

Referenced by StartThread().

◆ SetIOPriority() [2/2]

void cThread::SetIOPriority ( int  Priority)
protected

◆ SetMainThreadId() [1/2]

void cThread::SetMainThreadId ( void  )
static

Definition at line 377 of file thread.c.

References esyslog, mainThreadId, and ThreadId().

Referenced by main().

◆ SetMainThreadId() [2/2]

static void cThread::SetMainThreadId ( void  )
static

◆ SetPriority() [1/2]

void cThread::SetPriority ( int  Priority)
protected

Definition at line 255 of file thread.c.

References LOG_ERROR.

Referenced by StartThread().

◆ SetPriority() [2/2]

void cThread::SetPriority ( int  Priority)
protected

◆ Start() [1/2]

bool cThread::Start ( void  )

◆ Start() [2/2]

void 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.

◆ StartThread() [1/2]

void * cThread::StartThread ( cThread Thread)
staticprivate

Definition at line 279 of file thread.c.

References Action(), active, childThreadId, description, dsyslog, esyslog, lowPriority, running, SetIOPriority(), SetPriority(), and ThreadId().

Referenced by Start().

◆ StartThread() [2/2]

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

◆ ThreadId() [1/2]

tThreadId cThread::ThreadId ( void  )
static

◆ ThreadId() [2/2]

static tThreadId cThread::ThreadId ( void  )
static

◆ Unlock() [1/2]

void cThread::Unlock ( void  )
inlineprotected

◆ Unlock() [2/2]

void cThread::Unlock ( void  )
inlineprotected

Definition at line 95 of file thread.h.

References mutex, and cMutex::Unlock().

Friends And Related Function Documentation

◆ cThreadLock

cThreadLock
friend

Definition at line 80 of file include/vdr/thread.h.

Member Data Documentation

◆ active

bool cThread::active
private

Definition at line 82 of file include/vdr/thread.h.

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

◆ childThreadId

tThreadId cThread::childThreadId
private

Definition at line 85 of file include/vdr/thread.h.

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

◆ childTid

pthread_t cThread::childTid
private

Definition at line 84 of file include/vdr/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 include/vdr/thread.h.

Referenced by cThread(), and StartThread().

◆ mainThreadId

static tThreadId cThread::mainThreadId = 0
staticprivate

Definition at line 89 of file include/vdr/thread.h.

Referenced by IsMainThread(), and SetMainThreadId().

◆ mutex

cMutex cThread::mutex
private

Definition at line 86 of file include/vdr/thread.h.

Referenced by Lock(), and Unlock().

◆ running

bool cThread::running
private

Definition at line 83 of file include/vdr/thread.h.

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


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