From bb9158debbe8ac647e30bb15a250aa665ec60952 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 25 Sep 2018 15:44:43 +0800 Subject: [PATCH] common/ceph_mutex: add dummy mutex for WITH_SEASTAR Signed-off-by: Kefu Chai --- src/common/ceph_mutex.h | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/common/ceph_mutex.h b/src/common/ceph_mutex.h index 3c105ef7a6229..00eb3c72588f8 100644 --- a/src/common/ceph_mutex.h +++ b/src/common/ceph_mutex.h @@ -10,6 +10,39 @@ // The key requirement is that you make use of the ceph::make_mutex() // and make_recursive_mutex() factory methods, which take a string // naming the mutex for the purposes of the lockdep debug variant. + +#ifdef WITH_SEASTAR + +namespace ceph { + // an empty class satisfying the mutex concept + struct dummy_mutex { + void lock() {} + bool try_lock() { + return true; + } + void unlock() {} + }; + + using mutex = dummy_mutex; + using recursive_mutex = dummy_mutex; + // in seastar, we should use a difference interface for enforcing the + // semantics of condition_variable + + template + dummy_mutex make_mutex(Args&& ...args) { + return {}; + } + + template + recursive_mutex make_recursive_mutex(Args&& ...args) { + return {}; + } + + #define ceph_mutex_is_locked(m) true + #define ceph_mutex_is_locked_by_me(m) true +} + +#else // WITH_SEASTAR // // For legacy Mutex users that passed recursive=true, use // ceph::make_recursive_mutex. For legacy Mutex users that passed @@ -78,4 +111,6 @@ namespace ceph { #define ceph_mutex_is_locked_by_me(m) true } -#endif +#endif // CEPH_DEBUG_MUTEX + +#endif // WITH_SEASTAR -- 2.39.5