niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
henrike@webrtc.org | 686001d | 2013-03-26 14:16:05 +0000 | [diff] [blame^] | 11 | #include "webrtc/system_wrappers/interface/condition_variable_wrapper.h" |
| 12 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | #if defined(_WIN32) |
phoglund@webrtc.org | a36d75a | 2012-11-14 09:55:04 +0000 | [diff] [blame] | 14 | #include <windows.h> |
henrike@webrtc.org | 686001d | 2013-03-26 14:16:05 +0000 | [diff] [blame^] | 15 | #include "webrtc/system_wrappers/source/condition_variable_event_win.h" |
| 16 | #include "webrtc/system_wrappers/source/condition_variable_native_win.h" |
phoglund@webrtc.org | a36d75a | 2012-11-14 09:55:04 +0000 | [diff] [blame] | 17 | #elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC) |
| 18 | #include <pthread.h> |
henrike@webrtc.org | 686001d | 2013-03-26 14:16:05 +0000 | [diff] [blame^] | 19 | #include "webrtc/system_wrappers/source/condition_variable_posix.h" |
ajm@google.com | b5c49ff | 2011-08-01 17:04:04 +0000 | [diff] [blame] | 20 | #endif |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
phoglund@webrtc.org | a36d75a | 2012-11-14 09:55:04 +0000 | [diff] [blame] | 23 | |
| 24 | ConditionVariableWrapper* ConditionVariableWrapper::CreateConditionVariable() { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 25 | #if defined(_WIN32) |
henrike@webrtc.org | 686001d | 2013-03-26 14:16:05 +0000 | [diff] [blame^] | 26 | // Try to create native condition variable implementation. |
| 27 | ConditionVariableWrapper* ret_val = ConditionVariableNativeWin::Create(); |
| 28 | if (!ret_val) { |
| 29 | // Native condition variable implementation does not exist. Create generic |
| 30 | // condition variable based on events. |
| 31 | ret_val = new ConditionVariableEventWin(); |
| 32 | } |
| 33 | return ret_val; |
andrew@webrtc.org | f3b65db | 2012-09-06 18:17:00 +0000 | [diff] [blame] | 34 | #elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC) |
phoglund@webrtc.org | a36d75a | 2012-11-14 09:55:04 +0000 | [diff] [blame] | 35 | return ConditionVariablePosix::Create(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 36 | #else |
phoglund@webrtc.org | a36d75a | 2012-11-14 09:55:04 +0000 | [diff] [blame] | 37 | return NULL; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 38 | #endif |
| 39 | } |
phoglund@webrtc.org | a36d75a | 2012-11-14 09:55:04 +0000 | [diff] [blame] | 40 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 41 | } // namespace webrtc |