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