Skip to content

Commit

Permalink
reactor: get rid of reactor_notifier
Browse files Browse the repository at this point in the history
It is dead code, and stands in the way of creating new reactor_backends.
  • Loading branch information
avikivity committed Dec 16, 2018
1 parent c879bb5 commit 6293e60
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 134 deletions.
31 changes: 0 additions & 31 deletions include/seastar/core/reactor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,6 @@ private:
friend class readable_eventfd;
};

// The reactor_notifier interface is a simplified version of Linux's eventfd
// interface (with semaphore behavior off, and signal() always signaling 1).
//
// A call to signal() causes an ongoing wait() to invoke its continuation.
// If no wait() is ongoing, the next wait() will continue immediately.
class reactor_notifier {
public:
virtual future<> wait() = 0;
virtual void signal() = 0;
virtual ~reactor_notifier() {}
};

class thread_pool;
class smp;

Expand Down Expand Up @@ -413,7 +401,6 @@ private:
class thread_pool {
uint64_t _aio_threaded_fallbacks = 0;
#ifndef HAVE_OSV
// FIXME: implement using reactor_notifier abstraction we used for SMP
syscall_work_queue inter_thread_wq;
posix_thread _worker_thread;
std::atomic<bool> _stopped = { false };
Expand Down Expand Up @@ -471,12 +458,6 @@ public:
virtual future<> writeable(pollable_fd_state& fd) = 0;
virtual future<> readable_or_writeable(pollable_fd_state& fd) = 0;
virtual void forget(pollable_fd_state& fd) = 0;
// Methods that allow polling on a reactor_notifier. This is currently
// used only for reactor_backend_osv, but in the future it should really
// replace the above functions.
virtual future<> notified(reactor_notifier *n) = 0;
// Methods for allowing sending notifications events between threads.
virtual std::unique_ptr<reactor_notifier> make_reactor_notifier() = 0;
};

// reactor backend using file-descriptor & epoll, suitable for running on
Expand All @@ -498,16 +479,13 @@ public:
virtual future<> writeable(pollable_fd_state& fd) override;
virtual future<> readable_or_writeable(pollable_fd_state& fd) override;
virtual void forget(pollable_fd_state& fd) override;
virtual future<> notified(reactor_notifier *n) override;
virtual std::unique_ptr<reactor_notifier> make_reactor_notifier() override;
};

#ifdef HAVE_OSV
// reactor_backend using OSv-specific features, without any file descriptors.
// This implementation cannot currently wait on file descriptors, but unlike
// reactor_backend_epoll it doesn't need file descriptors for waiting on a
// timer, for example, so file descriptors are not necessary.
class reactor_notifier_osv;
class reactor_backend_osv : public reactor_backend {
private:
osv::newpoll::poller _poller;
Expand All @@ -520,10 +498,7 @@ public:
virtual future<> readable(pollable_fd_state& fd) override;
virtual future<> writeable(pollable_fd_state& fd) override;
virtual void forget(pollable_fd_state& fd) override;
virtual future<> notified(reactor_notifier *n) override;
virtual std::unique_ptr<reactor_notifier> make_reactor_notifier() override;
void enable_timer(steady_clock_type::time_point when);
friend class reactor_notifier_osv;
};
#endif /* HAVE_OSV */

Expand Down Expand Up @@ -1155,9 +1130,6 @@ public:
void forget(pollable_fd_state& fd) {
_backend.forget(fd);
}
future<> notified(reactor_notifier *n) {
return _backend.notified(n);
}
void abort_reader(pollable_fd_state& fd) {
// TCP will respond to shutdown(SHUT_RD) by returning ECONNABORT on the next read,
// but UDP responds by returning AGAIN. The no_more_recv flag tells us to convert
Expand All @@ -1173,9 +1145,6 @@ public:
return fd.fd.shutdown(SHUT_WR);
}
void enable_timer(steady_clock_type::time_point when);
std::unique_ptr<reactor_notifier> make_reactor_notifier() {
return _backend.make_reactor_notifier();
}
/// Sets the "Strict DMA" flag.
///
/// When true (default), file I/O operations must use DMA. This is
Expand Down
103 changes: 0 additions & 103 deletions src/core/reactor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -974,15 +974,6 @@ void reactor_backend_epoll::forget(pollable_fd_state& fd) {
}
}

future<> reactor_backend_epoll::notified(reactor_notifier *n) {
// Currently reactor_backend_epoll doesn't need to support notifiers,
// because we add to it file descriptors instead. But this can be fixed
// later.
std::cout << "reactor_backend_epoll does not yet support notifiers!\n";
abort();
}


pollable_fd
reactor::posix_listen(socket_address sa, listen_options opts) {
file_desc fd = file_desc::socket(sa.u.sa.sa_family, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, int(opts.proto));
Expand Down Expand Up @@ -4540,87 +4531,6 @@ __thread bool g_need_preempt;

__thread reactor* local_engine;

class reactor_notifier_epoll : public reactor_notifier {
writeable_eventfd _write;
readable_eventfd _read;
public:
reactor_notifier_epoll()
: _write()
, _read(_write.read_side()) {
}
virtual future<> wait() override {
// convert _read.wait(), a future<size_t>, to a future<>:
return _read.wait().then([] (size_t ignore) {
return make_ready_future<>();
});
}
virtual void signal() override {
_write.signal(1);
}
};

std::unique_ptr<reactor_notifier>
reactor_backend_epoll::make_reactor_notifier() {
return std::make_unique<reactor_notifier_epoll>();
}

#ifdef HAVE_OSV
class reactor_notifier_osv :
public reactor_notifier, private osv::newpoll::pollable {
promise<> _pr;
// TODO: pollable should probably remember its poller, so we shouldn't
// need to keep another copy of this pointer
osv::newpoll::poller *_poller = nullptr;
bool _needed = false;
public:
virtual future<> wait() override {
return engine().notified(this);
}
virtual void signal() override {
wake();
}
virtual void on_wake() override {
_pr.set_value();
_pr = promise<>();
// We try to avoid del()/add() ping-pongs: After an one occurance of
// the event, we don't del() but rather set needed=false. We guess
// the future's continuation (scheduler by _pr.set_value() above)
// will make the pollable needed again. Only if we reach this callback
// a second time, and needed is still false, do we finally del().
if (!_needed) {
_poller->del(this);
_poller = nullptr;

}
_needed = false;
}

void enable(osv::newpoll::poller &poller) {
_needed = true;
if (_poller == &poller) {
return;
}
assert(!_poller); // don't put same pollable on multiple pollers!
_poller = &poller;
_poller->add(this);
}

virtual ~reactor_notifier_osv() {
if (_poller) {
_poller->del(this);
}
}

friend class reactor_backend_osv;
};

std::unique_ptr<reactor_notifier>
reactor_backend_osv::make_reactor_notifier() {
return std::make_unique<reactor_notifier_osv>();
}
#endif


#ifdef HAVE_OSV
reactor_backend_osv::reactor_backend_osv() {
}
Expand All @@ -4638,19 +4548,6 @@ reactor_backend_osv::wait_and_process() {
return true;
}

future<>
reactor_backend_osv::notified(reactor_notifier *notifier) {
// reactor_backend_osv::make_reactor_notifier() generates a
// reactor_notifier_osv, so we only can work on such notifiers.
reactor_notifier_osv *n = dynamic_cast<reactor_notifier_osv *>(notifier);
if (n->read()) {
return make_ready_future<>();
}
n->enable(_poller);
return n->_pr.get_future();
}


future<>
reactor_backend_osv::readable(pollable_fd_state& fd) {
std::cout << "reactor_backend_osv does not support file descriptors - readable() shouldn't have been called!\n";
Expand Down

0 comments on commit 6293e60

Please sign in to comment.