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

Unified 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698