diff options
author | horchi <vdr@jwendel.de> | 2020-10-31 06:19:11 +0100 |
---|---|---|
committer | horchi <vdr@jwendel.de> | 2020-10-31 06:19:11 +0100 |
commit | 5675b5b9e4f06d6e4667db261f1a7d420cdd1ed4 (patch) | |
tree | 15fa6fb38702620845da96a7008109a813a14adb /lib/thread.h | |
parent | 449dda4ec3a0333538ba9e83a8066ae5ed10ca92 (diff) | |
download | vdr-epg-daemon-5675b5b9e4f06d6e4667db261f1a7d420cdd1ed4.tar.gz vdr-epg-daemon-5675b5b9e4f06d6e4667db261f1a7d420cdd1ed4.tar.bz2 |
dev
Diffstat (limited to 'lib/thread.h')
-rw-r--r-- | lib/thread.h | 81 |
1 files changed, 42 insertions, 39 deletions
diff --git a/lib/thread.h b/lib/thread.h index 1598ff2..fcaaf4b 100644 --- a/lib/thread.h +++ b/lib/thread.h @@ -10,6 +10,41 @@ #include "common.h" +class cCondWait +{ + public: + + cCondWait(); + ~cCondWait(); + + bool Wait(int TimeoutMs = 0); + void Signal(); + + static void SleepMs(int TimeoutMs); + + private: + + pthread_mutex_t mutex; + pthread_cond_t cond; + bool signaled; +}; + +class cCondVar +{ + public: + + cCondVar(); + ~cCondVar(); + + void Wait(cMyMutex &Mutex); + bool TimedWait(cMyMutex &Mutex, int TimeoutMs); + void Broadcast(); + + private: + + pthread_cond_t cond; +}; + //*************************************************************************** // Class cThread //*************************************************************************** @@ -22,10 +57,11 @@ class cThread virtual ~cThread(); void SetDescription(const char* Description, ...) __attribute__ ((format (printf, 2, 3))); - bool Start(int s = no); + bool Start(int s = no, int stackSize = na); bool Active(); void SetPriority(int priority); void SetIOPriority(int priority); + void Cancel(int WaitSeconds = 0); static pid_t ThreadId(); @@ -33,14 +69,12 @@ class cThread static void* StartThread(cThread *Thread); - bool active; - bool running; pthread_t childTid; pid_t childThreadId; - cMyMutex mutex; char* description; bool lowPriority; int silent; + pthread_attr_t attr; protected: @@ -49,42 +83,11 @@ class cThread void Lock() { mutex.Lock(); } void Unlock() { mutex.Unlock(); } bool Running() { return running; } - void Cancel(int WaitSeconds = 0); -}; - -class cCondWait -{ - public: - - cCondWait(); - ~cCondWait(); - - bool Wait(int TimeoutMs = 0); - void Signal(); - - static void SleepMs(int TimeoutMs); - - private: - - pthread_mutex_t mutex; - pthread_cond_t cond; - bool signaled; -}; - -class cCondVar -{ - public: - cCondVar(); - ~cCondVar(); - - void Wait(cMyMutex &Mutex); - bool TimedWait(cMyMutex &Mutex, int TimeoutMs); - void Broadcast(); - - private: - - pthread_cond_t cond; + cCondVar waitCondition; + cMyMutex mutex; + bool active; + bool running; }; //*************************************************************************** |