Go to the documentation of this file.
15 #include <sys/types.h>
27 static void SleepMs(
int TimeoutMs);
33 bool Wait(
int TimeoutMs = 0);
61 cRwLock(
bool PreferWriter =
false);
63 bool Lock(
bool Write,
int TimeoutMs = 0);
104 void Cancel(
int WaitSeconds = 0);
112 cThread(
const char *Description = NULL,
bool LowPriority =
false);
167 #define LOCK_THREAD cThreadLock ThreadLock(this)
188 bool Lock(
cStateKey &StateKey,
bool Write =
false,
int TimeoutMs = 0);
250 void Remove(
bool IncState =
true);
299 operator FILE* () {
return f; }
300 bool Open(
const char *Command,
const char *Mode);
323 static void BackTrace(FILE *f = NULL,
int Level = 0,
bool Mangled =
false);
340 int SystemExec(
const char *Command,
bool Detached =
false);
int SystemExec(const char *Command, bool Detached=false)
void Signal(void)
Signals a caller of Wait() that the condition it is waiting for is met.
cRwLock(bool PreferWriter=false)
void SetIOPriority(int Priority)
bool Lock(bool Write, int TimeoutMs=0)
bool InLock(void)
Returns true if this key is currently in a lock.
bool Active(void)
Returns true if this I/O throttling object is currently active.
cThreadLock(cThread *Thread=NULL)
void Cancel(int WaitSeconds=0)
Cancels the thread by first setting 'running' to false, so that the Action() loop can finish in an or...
void SetModified(void)
Sets this lock to have its state incremented when the current write lock state key is removed.
static tThreadId ThreadId(void)
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 Wait(int TimeoutMs=0)
Waits at most TimeoutMs milliseconds for a call to Signal(), or forever if TimeoutMs is 0.
bool Running(void)
Returns false if a derived cThread object shall leave its Action() function.
tThreadId writeLockThreadId
static void SetMainThreadId(void)
bool TimedOut(void) const
Returns true if the last lock attempt this key was used with failed due to a timeout.
static cString GetCaller(int Level=0, bool Mangled=false)
Returns the caller at the given Level (or the immediate caller, if Level is 0).
void SetPriority(int Priority)
cThread(const char *Description=NULL, bool LowPriority=false)
Creates a new thread.
void Remove(bool IncState=true)
Removes this key from the lock it was previously used with.
static cString Demangle(char *s)
Demangles the function name in the given string and returns the converted version of s.
static tThreadId IsMainThread(void)
static void * StartThread(cThread *Thread)
cStateLock(const char *Name=NULL)
bool Lock(cStateKey &StateKey, bool Write=false, int TimeoutMs=0)
Tries to get a lock and returns true if successful.
bool StateChanged(void)
Returns true if this key is used for obtaining a write lock, and the lock's state differs from that o...
bool Open(const char *Command, const char *Mode)
void SetSyncStateKey(cStateKey &StateKey)
Sets the given StateKey to be synchronized to the state of this lock.
static tThreadId mainThreadId
void Release(void)
Releases the global I/O throttling mechanism.
static void SleepMs(int TimeoutMs)
Creates a cCondWait object and uses it to sleep for TimeoutMs milliseconds, immediately giving up the...
bool Lock(cThread *Thread)
void SetExplicitModify(void)
If you have obtained a write lock on this lock, and you don't want its state to be automatically incr...
void Reset(void)
Resets the state of this key, so that the next call to a lock's Lock() function with this key will re...
bool Active(void)
Checks whether the thread is still alive.
void SetDescription(const char *Description,...) __attribute__((format(printf
bool TimedWait(cMutex &Mutex, int TimeoutMs)
cStateKey(bool IgnoreFirst=false)
Sets up a new state key.
cMutexLock(cMutex *Mutex=NULL)
void bool Start(void)
Sets the description of this thread, which will be used when logging starting or stopping of the thre...
void Activate(void)
Activates the global I/O throttling mechanism.
void Unlock(cStateKey &StateKey, bool IncState=true)
Releases a lock that has been obtained by a previous call to Lock() with the given StateKey.
static bool Engaged(void)
Returns true if any I/O throttling object is currently active.
static void BackTrace(cStringList &StringList, int Level=0, bool Mangled=false)
Produces a backtrace and stores it in the given StringList.
struct __attribute__((packed))