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() { | |
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 | |
OLD | NEW |