]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/RWLock: add RWLock::{lock,unlock}_shared()
authorKefu Chai <kchai@redhat.com>
Sun, 7 Jul 2019 03:21:12 +0000 (11:21 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 3 Aug 2019 03:27:19 +0000 (11:27 +0800)
so RWLock can be used with std::shared_lock,

rgw is using RWLock'prioritize_write feature, which is not offered by
std::shared_mutex, but we want to unify the way we use mutex, so add
these helper functions.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/common/RWLock.h

index 94ba7a00116401351e0b1e66010e974f3b07b4b6..08c8edc7b6d5e1dcdca8b1b5fa5edd6ea44ac9c9 100644 (file)
@@ -122,7 +122,12 @@ public:
   void put_read() const {
     unlock();
   }
-
+  void lock_shared() {
+    get_read();
+  }
+  void unlock_shared() {
+    put_read();
+  }
   // write
   void get_write(bool lockdep=true) {
     if (lockdep && this->lockdep && g_lockdep)
@@ -148,7 +153,9 @@ public:
   void put_write() {
     unlock();
   }
-
+  void lock() {
+    get_write();
+  }
   void get(bool for_write) {
     if (for_write) {
       get_write();