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
24namespace rtc {
25
26class Event {
27 public:
28  static const int kForever = -1;
29
30  Event(bool manual_reset, bool initially_signaled);
31  ~Event();
32
33  void Set();
34  void Reset();
35
36  // Wait for the event to become signaled, for the specified number of
37  // |milliseconds|.  To wait indefinetly, pass kForever.
38  bool Wait(int milliseconds);
39
40 private:
41#if defined(WEBRTC_WIN)
42  HANDLE event_handle_;
43#elif defined(WEBRTC_POSIX)
44  pthread_mutex_t event_mutex_;
45  pthread_cond_t event_cond_;
46  const bool is_manual_reset_;
47  bool event_status_;
48#endif
49};
50
51}  // namespace rtc
52
53#endif  // WEBRTC_BASE_EVENT_H__
54