From: Radoslaw Zarzynski Date: Mon, 21 Nov 2022 19:06:02 +0000 (+0000) Subject: common/ceph_mutex: add green thread-requiring condition variable for crimson X-Git-Tag: v18.1.0~260^2~33 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=89b322d387528bb77ee521f018d84692ee5eba66;p=ceph.git common/ceph_mutex: add green thread-requiring condition variable for crimson Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/common/ceph_mutex.h b/src/common/ceph_mutex.h index 81777c7dbe2a0..61cb650222048 100644 --- a/src/common/ceph_mutex.h +++ b/src/common/ceph_mutex.h @@ -15,6 +15,7 @@ // naming the mutex for the purposes of the lockdep debug variant. #if defined(WITH_SEASTAR) && !defined(WITH_ALIEN) +#include namespace ceph { // an empty class satisfying the mutex concept @@ -33,11 +34,26 @@ namespace ceph { void unlock_shared() {} }; + // this implementation assumes running within a seastar::thread + struct green_condition_variable : private seastar::condition_variable { + template + void wait(LockT&&) { + seastar::condition_variable::wait().get(); + } + + void notify_one() noexcept { + signal(); + } + + void notify_all() noexcept { + broadcast(); + } + }; + using mutex = dummy_mutex; using recursive_mutex = dummy_mutex; using shared_mutex = dummy_shared_mutex; - // in seastar, we should use a difference interface for enforcing the - // semantics of condition_variable + using condition_variable = green_condition_variable; template dummy_mutex make_mutex(Args&& ...args) {