cec: bump version to 1.6.3. check the client version, not the server version in libce...
[deb_libcec.git] / src / lib / platform / sockets / socket.h
index 58a3e3a751efbcad16462fc173a73917703e074f..f56d515c5e76676f95573555db07ad41523fe887 100644 (file)
@@ -105,7 +105,7 @@ namespace PLATFORM
   public:
     CProtectedSocket(_Socket *socket) :
       m_socket(socket),
-      m_iUseCount(0) {}
+      m_bIsIdle(true) {}
 
     virtual ~CProtectedSocket(void)
     {
@@ -151,13 +151,13 @@ namespace PLATFORM
     virtual bool IsBusy(void)
     {
       CLockObject lock(m_mutex);
-      return m_socket && m_iUseCount > 0;
+      return m_socket && !m_bIsIdle;
     }
 
-    virtual int GetUseCount(void)
+    virtual bool IsIdle(void)
     {
       CLockObject lock(m_mutex);
-      return m_iUseCount;
+      return m_socket && m_bIsIdle;
     }
 
     virtual ssize_t Write(void* data, size_t len)
@@ -208,27 +208,21 @@ namespace PLATFORM
     bool WaitReady(void)
     {
       CLockObject lock(m_mutex);
-      if (m_iUseCount > 0)
-        m_condition.Wait(m_mutex);
-
-      if (m_iUseCount > 0)
-        return false;
-
-      ++m_iUseCount;
+      m_condition.Wait(m_mutex, m_bIsIdle);
+      m_bIsIdle = false;
       return true;
     }
 
     void MarkReady(void)
     {
       CLockObject lock(m_mutex);
-      if (m_iUseCount > 0)
-        --m_iUseCount;
+      m_bIsIdle = true;
       m_condition.Signal();
     }
 
-    _Socket   *m_socket;
-    CMutex     m_mutex;
-    CCondition m_condition;
-    int        m_iUseCount;
+    _Socket *        m_socket;
+    CMutex           m_mutex;
+    CCondition<bool> m_condition;
+    bool             m_bIsIdle;
   };
 };