1/*
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
11#include "rw_lock_posix.h"
12
13namespace webrtc {
14RWLockPosix::RWLockPosix() : _lock()
15{
16}
17
18RWLockPosix::~RWLockPosix()
19{
20    pthread_rwlock_destroy(&_lock);
21}
22
23int RWLockPosix::Init()
24{
25    return pthread_rwlock_init(&_lock, 0);
26}
27
28void RWLockPosix::AcquireLockExclusive()
29{
30    pthread_rwlock_wrlock(&_lock);
31}
32
33void RWLockPosix::ReleaseLockExclusive()
34{
35    pthread_rwlock_unlock(&_lock);
36}
37
38void RWLockPosix::AcquireLockShared()
39{
40    pthread_rwlock_rdlock(&_lock);
41}
42
43void RWLockPosix::ReleaseLockShared()
44{
45    pthread_rwlock_unlock(&_lock);
46}
47} // namespace webrtc
48