blob: 0c4ce10157c21611169dbbeb73cd09318d590262 [file] [log] [blame]
hellner@google.com23a80652011-08-25 21:40:11 +00001/*
niklase@google.com470e71d2011-07-07 08:21:25 +00002 * Copyright (c) 2011 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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#include "system_wrappers/include/event_wrapper.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000012
13#if defined(_WIN32)
phoglund@webrtc.org5bbe0692012-12-10 10:44:37 +000014#include <windows.h>
sjlee@webrtc.org414fa7f2012-09-11 17:25:46 +000015#elif defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
phoglund@webrtc.org5bbe0692012-12-10 10:44:37 +000016#include <ApplicationServices/ApplicationServices.h>
niklase@google.com470e71d2011-07-07 08:21:25 +000017#endif
18
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "rtc_base/event.h"
Peter Boström64c03662015-04-08 11:24:19 +020020
niklase@google.com470e71d2011-07-07 08:21:25 +000021namespace webrtc {
Peter Boström64c03662015-04-08 11:24:19 +020022
23class EventWrapperImpl : public EventWrapper {
24 public:
Peter Boström64c03662015-04-08 11:24:19 +020025 ~EventWrapperImpl() override {}
26
27 bool Set() override {
28 event_.Set();
29 return true;
30 }
31
32 EventTypeWrapper Wait(unsigned long max_time) override {
Karl Wiberg79eb1d92017-11-08 12:26:07 +010033 int to_wait = max_time == WEBRTC_EVENT_INFINITE
34 ? rtc::Event::kForever
35 : static_cast<int>(max_time);
Peter Boström64c03662015-04-08 11:24:19 +020036 return event_.Wait(to_wait) ? kEventSignaled : kEventTimeout;
37 }
38
39 private:
40 rtc::Event event_;
41};
42
43// static
phoglund@webrtc.org5bbe0692012-12-10 10:44:37 +000044EventWrapper* EventWrapper::Create() {
Peter Boström64c03662015-04-08 11:24:19 +020045 return new EventWrapperImpl();
niklase@google.com470e71d2011-07-07 08:21:25 +000046}
Peter Boström64c03662015-04-08 11:24:19 +020047
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000048} // namespace webrtc