From c45113ba3cffcc8e0076919e95d87a817df45de6 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 25 Sep 2018 16:12:24 +0800 Subject: [PATCH] common/ceph_mutex: add shared_mutex to `ceph` namespace for the sake of completeness, also pave the road to ditch SharedMutex. 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 --- src/common/ceph_mutex.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/common/ceph_mutex.h b/src/common/ceph_mutex.h index 00eb3c72588f8..aac1bccdf0554 100644 --- a/src/common/ceph_mutex.h +++ b/src/common/ceph_mutex.h @@ -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 @@ -74,6 +76,12 @@ namespace ceph { return {std::forward(args)...}; } + // pass arguments to shared_mutex_debug ctor + template + shared_mutex make_shared_mutex(Args&& ...args) { + return {std::forward(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 #include +#include +#include + 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 @@ -103,6 +114,10 @@ namespace ceph { std::recursive_mutex make_recursive_mutex(Args&& ...args) { return {}; } + template + 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 -- 2.39.5