cec: fix some threading related bugs, like trying to join with a detached thread...
[deb_libcec.git] / src / lib / platform / threads.h
index 4ae5ac72557433464e96236e9821aee8ba414561..8b0729db4cf045dccbf3f1bf6777b5d33f6e0df2 100644 (file)
@@ -32,6 +32,7 @@
  */
 
 #include "os-dependent.h"
+#include <stdint.h>
 
 namespace CEC
 {
@@ -43,9 +44,10 @@ namespace CEC
     CCondition(void);
     virtual ~CCondition(void);
 
+    void Broadcast(void);
     void Signal(void);
     bool Wait(CMutex *mutex, int64_t iTimeout);
-    static void Sleep(int iTimeout);
+    static void Sleep(int64_t iTimeout);
 
   private:
     pthread_cond_t  m_cond;
@@ -87,14 +89,17 @@ namespace CEC
 
     virtual bool IsRunning(void) const { return m_bRunning; }
     virtual bool CreateThread(void);
-    virtual void StopThread(bool bWaitForExit = true);
+    virtual bool StopThread(bool bWaitForExit = true);
+    virtual bool Sleep(uint64_t iTimeout);
 
     static void *ThreadHandler(CThread *thread);
     virtual void *Process(void) = 0;
 
   protected:
-    pthread_t m_thread;
-    bool      m_bRunning;
-    bool      m_bStop;
+    pthread_t  m_thread;
+    CMutex     m_threadMutex;
+    CCondition m_threadCondition;
+    bool       m_bRunning;
+    bool       m_bStop;
   };
 };