mirror of
https://github.com/ceph/ceph
synced 2025-02-19 17:08:05 +00:00
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 <kchai@redhat.com>
This commit is contained in:
parent
71c0c491da
commit
5f05a50bae
@ -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
|
@ -10,11 +10,10 @@
|
||||
#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 {
|
||||
|
Loading…
Reference in New Issue
Block a user