From: Kefu Chai Date: Tue, 25 Sep 2018 08:12:24 +0000 (+0800) Subject: common/ceph_mutex: add shared_mutex to `ceph` namespace X-Git-Tag: v14.0.1~155^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c45113ba3cffcc8e0076919e95d87a817df45de6;p=ceph.git 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 --- diff --git a/src/common/ceph_mutex.h b/src/common/ceph_mutex.h index 00eb3c72588f..aac1bccdf055 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