niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
leozwang@webrtc.org | 785db5a | 2012-02-28 23:10:03 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
phoglund@webrtc.org | 59ad541 | 2012-12-18 15:20:35 +0000 | [diff] [blame] | 11 | #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 12 | |
pbos@webrtc.org | 7502543 | 2015-02-06 08:32:32 +0000 | [diff] [blame] | 13 | #include "webrtc/base/sharedexclusivelock.h" |
| 14 | #include "webrtc/base/thread_annotations.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 15 | |
| 16 | namespace webrtc { |
henrike@webrtc.org | 9f84723 | 2012-09-25 20:27:51 +0000 | [diff] [blame] | 17 | |
pbos@webrtc.org | 7502543 | 2015-02-06 08:32:32 +0000 | [diff] [blame] | 18 | class LOCKABLE RwLock : public RWLockWrapper { |
| 19 | virtual void AcquireLockExclusive() override EXCLUSIVE_LOCK_FUNCTION() { |
| 20 | lock_.LockExclusive(); |
henrike@webrtc.org | 9f84723 | 2012-09-25 20:27:51 +0000 | [diff] [blame] | 21 | } |
pbos@webrtc.org | 7502543 | 2015-02-06 08:32:32 +0000 | [diff] [blame] | 22 | 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 | |
| 37 | RWLockWrapper* RWLockWrapper::CreateRWLock() { |
| 38 | return new RwLock(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | } |
| 40 | |
henrike@webrtc.org | 9f84723 | 2012-09-25 20:27:51 +0000 | [diff] [blame] | 41 | } // namespace webrtc |