2011-07-07 08:21:25 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2011-08-01 17:04:04 +00:00
|
|
|
#include "rw_lock_posix.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2011-08-01 17:04:04 +00:00
|
|
|
RWLockPosix::RWLockPosix() : _lock()
|
2011-07-07 08:21:25 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-01 17:04:04 +00:00
|
|
|
RWLockPosix::~RWLockPosix()
|
2011-07-07 08:21:25 +00:00
|
|
|
{
|
|
|
|
|
pthread_rwlock_destroy(&_lock);
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-01 17:04:04 +00:00
|
|
|
int RWLockPosix::Init()
|
2011-07-07 08:21:25 +00:00
|
|
|
{
|
|
|
|
|
return pthread_rwlock_init(&_lock, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-01 17:04:04 +00:00
|
|
|
void RWLockPosix::AcquireLockExclusive()
|
2011-07-07 08:21:25 +00:00
|
|
|
{
|
|
|
|
|
pthread_rwlock_wrlock(&_lock);
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-01 17:04:04 +00:00
|
|
|
void RWLockPosix::ReleaseLockExclusive()
|
2011-07-07 08:21:25 +00:00
|
|
|
{
|
|
|
|
|
pthread_rwlock_unlock(&_lock);
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-01 17:04:04 +00:00
|
|
|
void RWLockPosix::AcquireLockShared()
|
2011-07-07 08:21:25 +00:00
|
|
|
{
|
|
|
|
|
pthread_rwlock_rdlock(&_lock);
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-01 17:04:04 +00:00
|
|
|
void RWLockPosix::ReleaseLockShared()
|
2011-07-07 08:21:25 +00:00
|
|
|
{
|
|
|
|
|
pthread_rwlock_unlock(&_lock);
|
|
|
|
|
}
|
|
|
|
|
} // namespace webrtc
|