blob: ae2a6b75d3ded38f073c267137651785d45c4972 [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
phoglund@webrtc.org59ad5412012-12-18 15:20:35 +000011#include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000012
pbos@webrtc.org75025432015-02-06 08:32:32 +000013#include "webrtc/base/sharedexclusivelock.h"
14#include "webrtc/base/thread_annotations.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000015
16namespace webrtc {
henrike@webrtc.org9f847232012-09-25 20:27:51 +000017
pbos@webrtc.org75025432015-02-06 08:32:32 +000018class LOCKABLE RwLock : public RWLockWrapper {
19 virtual void AcquireLockExclusive() override EXCLUSIVE_LOCK_FUNCTION() {
20 lock_.LockExclusive();
henrike@webrtc.org9f847232012-09-25 20:27:51 +000021 }
pbos@webrtc.org75025432015-02-06 08:32:32 +000022 virtual void ReleaseLockExclusive() override UNLOCK_FUNCTION() {
23 lock_.UnlockExclusive();
24 }
25
26 virtual void AcquireLockShared() override SHARED_LOCK_FUNCTION() {
27 lock_.LockShared();
28 }
29 virtual void ReleaseLockShared() override UNLOCK_FUNCTION() {
30 lock_.UnlockShared();
31 }
32
33 private:
34 rtc::SharedExclusiveLock lock_;
35};
36
37RWLockWrapper* RWLockWrapper::CreateRWLock() {
38 return new RwLock();
niklase@google.com470e71d2011-07-07 08:21:25 +000039}
40
henrike@webrtc.org9f847232012-09-25 20:27:51 +000041} // namespace webrtc