]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/ceph_mutex: add green thread-requiring condition variable for crimson
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Mon, 21 Nov 2022 19:06:02 +0000 (19:06 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 28 Feb 2023 16:22:04 +0000 (16:22 +0000)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/common/ceph_mutex.h

index 81777c7dbe2a0962a51685c76853f7b00a049881..61cb650222048b40555f4f1f3721f6dd4e6bf939 100644 (file)
@@ -15,6 +15,7 @@
 // naming the mutex for the purposes of the lockdep debug variant.
 
 #if defined(WITH_SEASTAR) && !defined(WITH_ALIEN)
+#include <seastar/core/condition-variable.hh>
 
 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 <class LockT>
+    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 <typename ...Args>
   dummy_mutex make_mutex(Args&& ...args) {