title: Linux/POSIX equivalent for Win32's CreateEvent, SetEvent, WaitForSingleObject
body: <p>I have written a small class for synchronizing threads of both Linux (actually Android) and Windows.</p>
  
  <p>Here is the Win32 implementation of my interface :</p>
  
  <pre><code>    class SyncObjectWin32 : public SyncObject
      {
      private:
  
          const HANDLE m_hEvent;
  
      public:
  
          SyncObjectWin32()
            : m_hEvent( ::CreateEvent( NULL, FALSE, FALSE ) )
          {
              if( NULL == m_hEvent )
                  throw core::Exception( "sys::SyncObjectWin32::SyncObjectWin32() - Failed to create event." );
          }
  
          ~SyncObjectWin32()
          {
              ::CloseHandle( m_hEvent );
          }
  
          void WaitForSignal()
          {
              ::WaitForSingleObject( m_hEvent );
          }
  
          void Signal()
          {
              ::SetEvent( m_hEvent );
          }
      };
  </code></pre>
  
  <p>The problem is that i'm not sure what would be the POSIX equivalent.
  So far i've written the following class, based on <a href="https://stackoverflow.com/questions/13030413/windows-event-implementation-in-linux-using-conditional-variables">this SO question</a>, but since the answer is incomplete i'm not sure about how to finish my class :</p>
  
  <pre><code>    class SyncObjectPosix
      {
      private:
  
          pthread_mutex_t m_oMutex;
  
      public:
  
          SyncObjectPosix()
          {
              pthread_mutex_lock( m_oMutex );                 // lock mutex
              bool &amp; signalled = find_signal( condition );  // find predicate
              signalled = true;                          // set predicate
              pthread_mutex_unlock( m_oMutex );               // unlock mutex
              pthread_cond_signal( condition );            // signal condition variable
          }
  
          ~SyncObjectPosix()
          {
  
          }
  
          void WaitForSignal()
          {
              pthread_mutex_lock(mutex);                         // lock mutex
              bool &amp; signalled = find_signal( condition );          // find predicate
              while (!signalled)
              {
                pthread_cond_timedwait(condition, m_oMutex, timeout);
              }
              signalled = false;                                 // reset predicate
              pthread_mutex_unlock( m_oMutex );                       // unlock mutex
          }
  
          void Signal()
          {
  
          }
      };
  </code></pre>