blob: d364bc0727a6f220b2467d537304b0624f462b4c [file] [log] [blame]
henrike@webrtc.orgf0488722014-05-13 18:00:26 +00001/*
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"
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000023
24namespace rtc {
25
26class Event {
27 public:
28 Event(bool manual_reset, bool initially_signaled);
29 ~Event();
30
31 void Set();
32 void Reset();
33 bool Wait(int cms);
34
35 private:
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000036#if defined(WEBRTC_WIN)
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000037 HANDLE event_handle_;
38#elif defined(WEBRTC_POSIX)
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000039 pthread_mutex_t event_mutex_;
40 pthread_cond_t event_cond_;
tommi@webrtc.org4c0fd962015-02-09 10:23:27 +000041 const bool is_manual_reset_;
42 bool event_status_;
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000043#endif
44};
45
46} // namespace rtc
47
48#endif // WEBRTC_BASE_EVENT_H__