blob: d3134684f293511e56f76fa85095f8a46a6e1cee [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
leozwang@webrtc.org785db5a2012-02-28 23:10:03 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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#include "rw_lock_wrapper.h"
12
13#include <assert.h>
14
15#if defined(_WIN32)
henrike@webrtc.org9f847232012-09-25 20:27:51 +000016#include "rw_lock_generic.h"
17#include "rw_lock_win.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000018#else
henrike@webrtc.org9f847232012-09-25 20:27:51 +000019#include "rw_lock_posix.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000020#endif
21
22namespace webrtc {
henrike@webrtc.org9f847232012-09-25 20:27:51 +000023
24RWLockWrapper* RWLockWrapper::CreateRWLock() {
niklase@google.com470e71d2011-07-07 08:21:25 +000025#ifdef _WIN32
henrike@webrtc.org9f847232012-09-25 20:27:51 +000026 // Native implementation is faster, so use that if available.
27 RWLockWrapper* lock = RWLockWin::Create();
28 if (lock) {
niklase@google.com470e71d2011-07-07 08:21:25 +000029 return lock;
henrike@webrtc.org9f847232012-09-25 20:27:51 +000030 }
31 return new RWLockGeneric();
32#else
33 return RWLockPosix::Create();
34#endif
niklase@google.com470e71d2011-07-07 08:21:25 +000035}
36
henrike@webrtc.org9f847232012-09-25 20:27:51 +000037} // namespace webrtc