blob: f36f7e24037fd42216108a822770e44ccf6dbb17 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
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.org686001d2013-03-26 14:16:05 +000011#include "webrtc/system_wrappers/interface/condition_variable_wrapper.h"
12
niklase@google.com470e71d2011-07-07 08:21:25 +000013#if defined(_WIN32)
phoglund@webrtc.orga36d75a2012-11-14 09:55:04 +000014#include <windows.h>
henrike@webrtc.org686001d2013-03-26 14:16:05 +000015#include "webrtc/system_wrappers/source/condition_variable_event_win.h"
16#include "webrtc/system_wrappers/source/condition_variable_native_win.h"
phoglund@webrtc.orga36d75a2012-11-14 09:55:04 +000017#elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC)
18#include <pthread.h>
henrike@webrtc.org686001d2013-03-26 14:16:05 +000019#include "webrtc/system_wrappers/source/condition_variable_posix.h"
ajm@google.comb5c49ff2011-08-01 17:04:04 +000020#endif
niklase@google.com470e71d2011-07-07 08:21:25 +000021
22namespace webrtc {
phoglund@webrtc.orga36d75a2012-11-14 09:55:04 +000023
24ConditionVariableWrapper* ConditionVariableWrapper::CreateConditionVariable() {
niklase@google.com470e71d2011-07-07 08:21:25 +000025#if defined(_WIN32)
henrike@webrtc.org686001d2013-03-26 14:16:05 +000026 // 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.orgf3b65db2012-09-06 18:17:00 +000034#elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC)
phoglund@webrtc.orga36d75a2012-11-14 09:55:04 +000035 return ConditionVariablePosix::Create();
niklase@google.com470e71d2011-07-07 08:21:25 +000036#else
phoglund@webrtc.orga36d75a2012-11-14 09:55:04 +000037 return NULL;
niklase@google.com470e71d2011-07-07 08:21:25 +000038#endif
39}
phoglund@webrtc.orga36d75a2012-11-14 09:55:04 +000040
niklase@google.com470e71d2011-07-07 08:21:25 +000041} // namespace webrtc