Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(518)

Side by Side Diff: base/synchronization/rw_lock_nacl.cc

Issue 1988563002: Create a reader-writer lock implementaiton in base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simple-stupid implementaiton for NaCl Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698