15 #include <sys/types.h> 27 static void SleepMs(
int TimeoutMs);
33 bool Wait(
int TimeoutMs = 0);
51 bool TimedWait(
cMutex &Mutex,
int TimeoutMs);
61 cRwLock(
bool PreferWriter =
false);
63 bool Lock(
bool Write,
int TimeoutMs = 0);
90 static void *StartThread(
cThread *Thread);
92 void SetPriority(
int Priority);
93 void SetIOPriority(
int Priority);
96 virtual void Action(
void) = 0;
104 void Cancel(
int WaitSeconds = 0);
112 cThread(
const char *Description = NULL,
bool LowPriority =
false);
120 void SetDescription(
const char *Description, ...) __attribute__ ((format (printf, 2, 3)));
132 static void SetMainThreadId(
void);
167 #define LOCK_THREAD cThreadLock ThreadLock(this) 174 enum { emDisabled = 0, emArmed, emEnabled };
181 void Unlock(
cStateKey &StateKey,
bool IncState =
true);
188 bool Lock(
cStateKey &StateKey,
bool Write =
false,
int TimeoutMs = 0);
216 void SetSyncStateKey(
cStateKey &StateKey);
222 void SetExplicitModify(
void);
227 void SetModified(
void);
250 void Remove(
bool IncState =
true);
255 bool StateChanged(
void);
285 static bool Engaged(
void);
299 operator FILE* () {
return f; }
300 bool Open(
const char *Command,
const char *Mode);
311 static cString Demangle(
char *s);
318 static void BackTrace(
cStringList &StringList,
int Level = 0,
bool Mangled =
false);
323 static void BackTrace(FILE *f = NULL,
int Level = 0,
bool Mangled =
false);
328 static cString GetCaller(
int Level = 0,
bool Mangled =
false);
340 int SystemExec(
const char *Command,
bool Detached =
false);
bool Active(void)
Returns true if this I/O throttling object is currently active.
bool TimedOut(void) const
Returns true if the last lock attempt this key was used with failed due to a timeout.
void Signal(void)
Signals a caller of Wait() that the condition it is waiting for is met.
static tThreadId IsMainThread(void)
tThreadId writeLockThreadId
static void SleepMs(int TimeoutMs)
Creates a cCondWait object and uses it to sleep for TimeoutMs milliseconds, immediately giving up the...
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...
int SystemExec(const char *Command, bool Detached=false)
static tThreadId mainThreadId
bool InLock(void)
Returns true if this key is currently in a lock.