| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/system_wrappers/source/rw_lock_posix.h" | 11 #include "webrtc/system_wrappers/source/rw_lock_posix.h" |
| 12 | 12 |
| 13 namespace webrtc { | 13 namespace webrtc { |
| 14 | 14 |
| 15 RWLockPosix::RWLockPosix() : lock_() { | 15 RWLockPosix::RWLockPosix() : lock_() { |
| 16 } | 16 } |
| 17 | 17 |
| 18 RWLockPosix::~RWLockPosix() { | 18 RWLockPosix::~RWLockPosix() { |
| 19 pthread_rwlock_destroy(&lock_); | 19 pthread_rwlock_destroy(&lock_); |
| 20 } | 20 } |
| 21 | 21 |
| 22 RWLockPosix* RWLockPosix::Create() { | 22 RWLockPosix* RWLockPosix::Create() { |
| 23 RWLockPosix* ret_val = new RWLockPosix(); | 23 RWLockPosix* ret_val = new RWLockPosix(); |
| 24 if (!ret_val->Init()) { | 24 if (!ret_val->Init()) { |
| 25 delete ret_val; | 25 delete ret_val; |
| 26 return NULL; | 26 return nullptr; |
| 27 } | 27 } |
| 28 return ret_val; | 28 return ret_val; |
| 29 } | 29 } |
| 30 | 30 |
| 31 bool RWLockPosix::Init() { | 31 bool RWLockPosix::Init() { |
| 32 return pthread_rwlock_init(&lock_, 0) == 0; | 32 return pthread_rwlock_init(&lock_, 0) == 0; |
| 33 } | 33 } |
| 34 | 34 |
| 35 void RWLockPosix::AcquireLockExclusive() { | 35 void RWLockPosix::AcquireLockExclusive() { |
| 36 pthread_rwlock_wrlock(&lock_); | 36 pthread_rwlock_wrlock(&lock_); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void RWLockPosix::ReleaseLockExclusive() { | 39 void RWLockPosix::ReleaseLockExclusive() { |
| 40 pthread_rwlock_unlock(&lock_); | 40 pthread_rwlock_unlock(&lock_); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void RWLockPosix::AcquireLockShared() { | 43 void RWLockPosix::AcquireLockShared() { |
| 44 pthread_rwlock_rdlock(&lock_); | 44 pthread_rwlock_rdlock(&lock_); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void RWLockPosix::ReleaseLockShared() { | 47 void RWLockPosix::ReleaseLockShared() { |
| 48 pthread_rwlock_unlock(&lock_); | 48 pthread_rwlock_unlock(&lock_); |
| 49 } | 49 } |
| 50 | 50 |
| 51 } // namespace webrtc | 51 } // namespace webrtc |
| OLD | NEW |