Commit f22220e5 authored by Hans Fugal's avatar Hans Fugal Committed by Dave Watson

Have EventBase implement wangle::Executor

Summary:
It already does the work (`runInEventBaseThread`) but it will now be convenient to pass an `EventBase` where wangle wants an `Executor`.

Had to rip off the `boost::noncopyable` from `wangle::Executor` which is an interface and does not require non-copyability so that didn't really belong there in the first place I think. (Without this change, you get an obscure compiler error because of the double-inheritance from `boost::noncopyable`).

Test Plan: Things build, tests pass

Reviewed By: davejwatson@fb.com

Subscribers: jsedgwick, trunkagent, fugalh, exa, njormrod, folly-diffs@, andrii

FB internal diff: D1671500

Signature: t1:1671500:1415727572:a7dba33c669ca122aecaee3c700f9e53e54838d1
parent 3c34f066
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <glog/logging.h> #include <glog/logging.h>
#include <folly/io/async/AsyncTimeout.h> #include <folly/io/async/AsyncTimeout.h>
#include <folly/io/async/TimeoutManager.h> #include <folly/io/async/TimeoutManager.h>
#include <folly/wangle/Executor.h>
#include <memory> #include <memory>
#include <stack> #include <stack>
#include <list> #include <list>
...@@ -68,7 +69,9 @@ class EventBaseObserver { ...@@ -68,7 +69,9 @@ class EventBaseObserver {
* EventBase from other threads. When it is safe to call a method from * EventBase from other threads. When it is safe to call a method from
* another thread it is explicitly listed in the method comments. * another thread it is explicitly listed in the method comments.
*/ */
class EventBase : private boost::noncopyable, public TimeoutManager { class EventBase :
private boost::noncopyable, public TimeoutManager, public wangle::Executor
{
public: public:
/** /**
* A callback interface to use with runInLoop() * A callback interface to use with runInLoop()
...@@ -447,6 +450,13 @@ class EventBase : private boost::noncopyable, public TimeoutManager { ...@@ -447,6 +450,13 @@ class EventBase : private boost::noncopyable, public TimeoutManager {
*/ */
const std::string& getName(); const std::string& getName();
/// Implements the wangle::Executor interface
void add(Cob fn) override {
// runInEventBaseThread() takes a const&,
// so no point in doing std::move here.
runInEventBaseThread(fn);
}
private: private:
// TimeoutManager // TimeoutManager
......
...@@ -24,7 +24,7 @@ namespace folly { namespace wangle { ...@@ -24,7 +24,7 @@ namespace folly { namespace wangle {
/// An Executor accepts units of work with add(), which should be /// An Executor accepts units of work with add(), which should be
/// threadsafe. /// threadsafe.
class Executor : boost::noncopyable { class Executor {
public: public:
virtual ~Executor() = default; virtual ~Executor() = default;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment