hellner@google.com | 23a8065 | 2011-08-25 21:40:11 +0000 | [diff] [blame] | 1 | /* |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 2 | * 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 | |
Henrik Kjellander | 98f5351 | 2015-10-28 18:17:40 +0100 | [diff] [blame] | 11 | #include "webrtc/system_wrappers/include/event_wrapper.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 12 | |
| 13 | #if defined(_WIN32) |
phoglund@webrtc.org | 5bbe069 | 2012-12-10 10:44:37 +0000 | [diff] [blame] | 14 | #include <windows.h> |
Peter Boström | 64c0366 | 2015-04-08 11:24:19 +0200 | [diff] [blame] | 15 | #include "webrtc/system_wrappers/source/event_timer_win.h" |
sjlee@webrtc.org | 414fa7f | 2012-09-11 17:25:46 +0000 | [diff] [blame] | 16 | #elif defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) |
phoglund@webrtc.org | 5bbe069 | 2012-12-10 10:44:37 +0000 | [diff] [blame] | 17 | #include <ApplicationServices/ApplicationServices.h> |
| 18 | #include <pthread.h> |
Peter Boström | 64c0366 | 2015-04-08 11:24:19 +0200 | [diff] [blame] | 19 | #include "webrtc/system_wrappers/source/event_timer_posix.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 20 | #else |
phoglund@webrtc.org | 5bbe069 | 2012-12-10 10:44:37 +0000 | [diff] [blame] | 21 | #include <pthread.h> |
Peter Boström | 64c0366 | 2015-04-08 11:24:19 +0200 | [diff] [blame] | 22 | #include "webrtc/system_wrappers/source/event_timer_posix.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 23 | #endif |
| 24 | |
Peter Boström | 64c0366 | 2015-04-08 11:24:19 +0200 | [diff] [blame] | 25 | #include "webrtc/base/event.h" |
| 26 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 27 | namespace webrtc { |
Peter Boström | 64c0366 | 2015-04-08 11:24:19 +0200 | [diff] [blame] | 28 | |
| 29 | class EventWrapperImpl : public EventWrapper { |
| 30 | public: |
| 31 | EventWrapperImpl() : event_(false, false) {} |
| 32 | ~EventWrapperImpl() override {} |
| 33 | |
| 34 | bool Set() override { |
| 35 | event_.Set(); |
| 36 | return true; |
| 37 | } |
| 38 | |
| 39 | EventTypeWrapper Wait(unsigned long max_time) override { |
| 40 | int to_wait = max_time == WEBRTC_EVENT_INFINITE ? |
| 41 | rtc::Event::kForever : static_cast<int>(max_time); |
| 42 | return event_.Wait(to_wait) ? kEventSignaled : kEventTimeout; |
| 43 | } |
| 44 | |
| 45 | private: |
| 46 | rtc::Event event_; |
| 47 | }; |
| 48 | |
| 49 | // static |
phoglund@webrtc.org | 5bbe069 | 2012-12-10 10:44:37 +0000 | [diff] [blame] | 50 | EventWrapper* EventWrapper::Create() { |
Peter Boström | 64c0366 | 2015-04-08 11:24:19 +0200 | [diff] [blame] | 51 | return new EventWrapperImpl(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 52 | } |
Peter Boström | 64c0366 | 2015-04-08 11:24:19 +0200 | [diff] [blame] | 53 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 54 | } // namespace webrtc |