From: Kefu Chai Date: Thu, 13 Feb 2020 04:27:29 +0000 (+0800) Subject: crimson/thread: s/Condition/seastar::readable_eventfd/ X-Git-Tag: v15.1.1~444^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5f05a50bae8bb4889dba0d249ed5fc3a2fcdcfa5;p=ceph.git crimson/thread: s/Condition/seastar::readable_eventfd/ 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 --- diff --git a/src/crimson/thread/Condition.h b/src/crimson/thread/Condition.h deleted file mode 100644 index 1d95048218ba..000000000000 --- a/src/crimson/thread/Condition.h +++ /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 -#include - -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 diff --git a/src/crimson/thread/ThreadPool.h b/src/crimson/thread/ThreadPool.h index d648a6b6ed79..1f44715615a2 100644 --- a/src/crimson/thread/ThreadPool.h +++ b/src/crimson/thread/ThreadPool.h @@ -10,11 +10,10 @@ #include #include #include +#include #include #include -#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 {