OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/synchronization/rw_lock.h" | |
6 | |
7 #include "base/logging.h" | |
8 | |
9 namespace base { | |
10 | |
11 RWLock::RWLock() {} | |
12 | |
13 RWLock::~RWLock() { | |
14 DCHECK_EQ(0u, readers_); | |
15 } | |
16 | |
17 void RWLock::ReadAcquire() { | |
18 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.
| |
19 readers_++; | |
20 if (readers_ == 1) | |
21 writer_lock_.Acquire(); | |
22 } | |
23 | |
24 void RWLock::ReadRelease() { | |
25 AutoLock l(native_handle_); | |
26 readers_--; | |
27 if (readers_ == 0) | |
28 writer_lock_.Release(); | |
29 } | |
30 | |
31 void RWLock::WriteAcquire() { | |
32 writer_lock_.Acquire(); | |
33 } | |
34 | |
35 void RWLock::WriteRelease() { | |
36 writer_lock_.Release(); | |
37 } | |
38 | |
39 } // namespace base | |
OLD | NEW |