]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/thread: s/Condition/seastar::readable_eventfd/
authorKefu Chai <kchai@redhat.com>
Thu, 13 Feb 2020 04:27:29 +0000 (12:27 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 13 Feb 2020 06:53:55 +0000 (14:53 +0800)
in the latest version of seastar, we are not able to construct a
`seastar::pollable_fd_state` directly, as its constructor is now
`protected`, and only the reactor is able to create an instance of
`seastar::pollable_fd_state` now.

and `seastar::readable_eventfd` offers all we need to get notified
by reactor in an alien world. so let's used it instead.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/thread/Condition.h [deleted file]
src/crimson/thread/ThreadPool.h

diff --git a/src/crimson/thread/Condition.h b/src/crimson/thread/Condition.h
deleted file mode 100644 (file)
index 1d95048..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-
-#pragma once
-
-#include <seastar/core/reactor.hh>
-#include <sys/eventfd.h>
-
-namespace crimson::thread {
-
-/// a synchronization primitive can be used to block a seastar thread, until
-/// another thread notifies it.
-class Condition {
-  seastar::file_desc file_desc;
-  int fd;
-  seastar::pollable_fd_state fd_state;
-  eventfd_t event = 0;
-public:
-  Condition()
-    : file_desc{seastar::file_desc::eventfd(0, 0)},
-      fd(file_desc.get()),
-      fd_state{std::move(file_desc)}
-  {}
-  seastar::future<> wait() {
-    return seastar::engine().read_some(fd_state, &event, sizeof(event))
-      .then([](size_t) {
-         return seastar::now();
-       });
-  }
-  void notify() {
-    eventfd_t result = 1;
-    ::eventfd_write(fd, result);
-  }
-};
-
-} // namespace crimson::thread
index d648a6b6ed79c8b59f3c0ffff3206b80fb0dc61d..1f44715615a234dc612905e506eda7b882ec8ee7 100644 (file)
 #include <boost/optional.hpp>
 #include <seastar/core/future.hh>
 #include <seastar/core/gate.hh>
+#include <seastar/core/reactor.hh>
 #include <seastar/core/semaphore.hh>
 #include <seastar/core/sharded.hh>
 
-#include "Condition.h"
-
 namespace crimson::thread {
 
 struct WorkItem {
@@ -44,10 +43,10 @@ public:
     } catch (...) {
       state.set_exception(std::current_exception());
     }
-    on_done.notify();
+    on_done.write_side().signal(1);
   }
   typename futurator_t::type get_future() {
-    return on_done.wait().then([this] {
+    return on_done.wait().then([this](size_t) {
       if (state.failed()) {
        return futurator_t::make_exception_future(state.get_exception());
       } else {
@@ -58,7 +57,7 @@ public:
 private:
   Func func;
   future_state_t state;
-  crimson::thread::Condition on_done;
+  seastar::readable_eventfd on_done;
 };
 
 struct SubmitQueue {