15 #include <sys/types.h>
25 static void SleepMs(
int TimeoutMs);
31 bool Wait(
int TimeoutMs = 0);
57 cRwLock(
bool PreferWriter =
false);
59 bool Lock(
bool Write,
int TimeoutMs = 0);
94 virtual void Action(
void) = 0;
102 void Cancel(
int WaitSeconds = 0);
110 cThread(
const char *Description = NULL,
bool LowPriority =
false);
118 void SetDescription(
const char *Description, ...) __attribute__ ((format (printf, 2, 3)));
165 #define LOCK_THREAD cThreadLock ThreadLock(this)
199 operator FILE* () {
return f; }
200 bool Open(
const char *Command,
const char *Mode);
209 int SystemExec(
const char *Command,
bool Detached =
false);
virtual void Action(void)=0
A derived cThread class must implement the code it wants to execute as a separate thread in this func...
bool Active(void)
Returns true if this I/O throttling object is currently active.
void SetDescription(const char *Description,...) __attribute__((format(printf
void Signal(void)
Signals a caller of Wait() that the condition it is waiting for is met.
void SetPriority(int Priority)
cThreadLock(cThread *Thread=NULL)
static tThreadId IsMainThread(void)
cRwLock(bool PreferWriter=false)
cMutexLock(cMutex *Mutex=NULL)
static void SleepMs(int TimeoutMs)
Creates a cCondWait object and uses it to sleep for TimeoutMs milliseconds, immediately giving up the...
static void * StartThread(cThread *Thread)
void bool Start(void)
Sets the description of this thread, which will be used when logging starting or stopping of the thre...
bool Open(const char *Command, const char *Mode)
bool Lock(bool Write, int TimeoutMs=0)
bool Running(void)
Returns false if a derived cThread object shall leave its Action() function.
bool Wait(int TimeoutMs=0)
Waits at most TimeoutMs milliseconds for a call to Signal(), or forever if TimeoutMs is 0...
static tThreadId ThreadId(void)
bool TimedWait(cMutex &Mutex, int TimeoutMs)
void Activate(void)
Activates the global I/O throttling mechanism.
void SetIOPriority(int Priority)
static void SetMainThreadId(void)
bool Active(void)
Checks whether the thread is still alive.
static bool Engaged(void)
Returns true if any I/O throttling object is currently active.
int SystemExec(const char *Command, bool Detached=false)
cThread(const char *Description=NULL, bool LowPriority=false)
Creates a new thread.
bool Lock(cThread *Thread)
void Cancel(int WaitSeconds=0)
Cancels the thread by first setting 'running' to false, so that the Action() loop can finish in an or...
static tThreadId mainThreadId
void Release(void)
Releases the global I/O throttling mechanism.