Home | History | Annotate | Download | only in base
      1 /*
      2  *  Copyright 2004 The WebRTC Project Authors. All rights reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 #ifndef WEBRTC_BASE_EVENT_H__
     12 #define WEBRTC_BASE_EVENT_H__
     13 
     14 #if defined(WEBRTC_WIN)
     15 #include "webrtc/base/win32.h"  // NOLINT: consider this a system header.
     16 #elif defined(WEBRTC_POSIX)
     17 #include <pthread.h>
     18 #else
     19 #error "Must define either WEBRTC_WIN or WEBRTC_POSIX."
     20 #endif
     21 
     22 #include "webrtc/base/basictypes.h"
     23 #include "webrtc/base/common.h"
     24 
     25 namespace rtc {
     26 
     27 class Event {
     28  public:
     29   Event(bool manual_reset, bool initially_signaled);
     30   ~Event();
     31 
     32   void Set();
     33   void Reset();
     34   bool Wait(int cms);
     35 
     36  private:
     37   bool is_manual_reset_;
     38 
     39 #if defined(WEBRTC_WIN)
     40   bool is_initially_signaled_;
     41   HANDLE event_handle_;
     42 #elif defined(WEBRTC_POSIX)
     43   bool event_status_;
     44   pthread_mutex_t event_mutex_;
     45   pthread_cond_t event_cond_;
     46 #endif
     47 };
     48 
     49 }  // namespace rtc
     50 
     51 #endif  // WEBRTC_BASE_EVENT_H__
     52