Chromium Code Reviews| Index: base/synchronization/rw_lock_nacl.cc |
| diff --git a/base/synchronization/rw_lock_nacl.cc b/base/synchronization/rw_lock_nacl.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4698d2d5f1df79a75bc5c42a34c46b16e1c953a3 |
| --- /dev/null |
| +++ b/base/synchronization/rw_lock_nacl.cc |
| @@ -0,0 +1,39 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/synchronization/rw_lock.h" |
| + |
| +#include "base/logging.h" |
| + |
| +namespace base { |
| + |
| +RWLock::RWLock() {} |
| + |
| +RWLock::~RWLock() { |
| + DCHECK_EQ(0u, readers_); |
| +} |
| + |
| +void RWLock::ReadAcquire() { |
| + AutoLock l(native_handle_); |
|
danakj
2016/05/19 23:01:37
nit: name var "hold". ditto elsewhere
Anand Mistry (off Chromium)
2016/05/20 04:06:38
Done.
|
| + readers_++; |
| + if (readers_ == 1) |
| + writer_lock_.Acquire(); |
| +} |
| + |
| +void RWLock::ReadRelease() { |
| + AutoLock l(native_handle_); |
| + readers_--; |
| + if (readers_ == 0) |
| + writer_lock_.Release(); |
| +} |
| + |
| +void RWLock::WriteAcquire() { |
| + writer_lock_.Acquire(); |
| +} |
| + |
| +void RWLock::WriteRelease() { |
| + writer_lock_.Release(); |
| +} |
| + |
| +} // namespace base |