]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/ceph_mutex: add shared_mutex to `ceph` namespace
authorKefu Chai <kchai@redhat.com>
Tue, 25 Sep 2018 08:12:24 +0000 (16:12 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 27 Sep 2018 13:34:05 +0000 (21:34 +0800)
for the sake of completeness, also pave the road to ditch
SharedMutex<LockPolicy>. please note, in code used by crimson, we are
not using shared_mutex or SharedMutex yet. so we are not adding
the dummy shared_mutex for WITH_SEASTAR.

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

index 00eb3c72588f8445e5d1d17fadf9eb61017c5a01..aac1bccdf0554bcb7176713e53d75c347a2d45e4 100644 (file)
@@ -54,13 +54,15 @@ namespace ceph {
 // debug (lockdep-capable, various sanity checks and asserts)
 // ============================================================================
 
-#include "common/mutex_debug.h"
 #include "common/condition_variable_debug.h"
+#include "common/mutex_debug.h"
+#include "common/shared_mutex_debug.h"
 
 namespace ceph {
   typedef ceph::mutex_debug mutex;
   typedef ceph::mutex_recursive_debug recursive_mutex;
   typedef ceph::condition_variable_debug condition_variable;
+  typedef ceph::shared_mutex_debug shared_mutex;
 
   // pass arguments to mutex_debug ctor
   template <typename ...Args>
@@ -74,6 +76,12 @@ namespace ceph {
     return {std::forward<Args>(args)...};
   }
 
+  // pass arguments to shared_mutex_debug ctor
+  template <typename ...Args>
+  shared_mutex make_shared_mutex(Args&& ...args) {
+    return {std::forward<Args>(args)...};
+  }
+
   // debug methods
   #define ceph_mutex_is_locked(m) ((m).is_locked())
   #define ceph_mutex_is_locked_by_me(m) ((m).is_locked_by_me())
@@ -85,14 +93,17 @@ namespace ceph {
 // release (fast and minimal)
 // ============================================================================
 
-#include <mutex>
 #include <condition_variable>
+#include <mutex>
+#include <shared_mutex>
+
 
 namespace ceph {
 
   typedef std::mutex mutex;
   typedef std::recursive_mutex recursive_mutex;
   typedef std::condition_variable condition_variable;
+  typedef std::shared_mutex shared_mutex;
 
   // discard arguments to make_mutex (they are for debugging only)
   template <typename ...Args>
@@ -103,6 +114,10 @@ namespace ceph {
   std::recursive_mutex make_recursive_mutex(Args&& ...args) {
     return {};
   }
+  template <typename ...Args>
+  std::shared_mutex make_shared_mutex(Args&& ...args) {
+    return {};
+  }
 
   // debug methods.  Note that these can blindly return true
   // because any code that does anything other than assert these