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

Side by Side Diff: base/synchronization/rw_lock_posix.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() {
danakj 2016/05/19 23:01:37 can you use PTHREAD_RWLOCK_INITIALIZER similar to
Anand Mistry (off Chromium) 2016/05/20 04:06:38 Done. Oddly enough, the man on Linux doesn't say
12 int rv = pthread_rwlock_init(&native_handle_, nullptr);
danakj 2016/05/19 23:01:37 nit: name "result" instead of rv. ditto elsewhere
Anand Mistry (off Chromium) 2016/05/20 04:06:38 Done.
13 DCHECK_EQ(rv, 0) << ". " << strerror(rv);
14 }
15
16 RWLock::~RWLock() {
17 int rv = pthread_rwlock_destroy(&native_handle_);
18 DCHECK_EQ(rv, 0) << ". " << strerror(rv);
19 }
20
21 void RWLock::ReadAcquire() {
22 int rv = pthread_rwlock_rdlock(&native_handle_);
23 DCHECK_EQ(rv, 0) << ". " << strerror(rv);
24 }
25
26 void RWLock::ReadRelease() {
27 int rv = pthread_rwlock_unlock(&native_handle_);
28 DCHECK_EQ(rv, 0) << ". " << strerror(rv);
29 }
30
31 void RWLock::WriteAcquire() {
32 int rv = pthread_rwlock_wrlock(&native_handle_);
33 DCHECK_EQ(rv, 0) << ". " << strerror(rv);
34 }
35
36 void RWLock::WriteRelease() {
37 int rv = pthread_rwlock_unlock(&native_handle_);
38 DCHECK_EQ(rv, 0) << ". " << strerror(rv);
39 }
40
41 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698