From f22220e57b6df810439325e718682eb7c2800a99 Mon Sep 17 00:00:00 2001 From: Hans Fugal Date: Wed, 12 Nov 2014 10:01:50 -0800 Subject: [PATCH] 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 --- folly/io/async/EventBase.h | 12 +++++++++++- folly/wangle/Executor.h | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/folly/io/async/EventBase.h b/folly/io/async/EventBase.h index 98d5769c..3da2169d 100644 --- a/folly/io/async/EventBase.h +++ b/folly/io/async/EventBase.h @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -68,7 +69,9 @@ class EventBaseObserver { * EventBase from other threads. When it is safe to call a method from * 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: /** * A callback interface to use with runInLoop() @@ -447,6 +450,13 @@ class EventBase : private boost::noncopyable, public TimeoutManager { */ 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: // TimeoutManager diff --git a/folly/wangle/Executor.h b/folly/wangle/Executor.h index cc9ce34d..b7c31fb7 100644 --- a/folly/wangle/Executor.h +++ b/folly/wangle/Executor.h @@ -24,7 +24,7 @@ namespace folly { namespace wangle { /// An Executor accepts units of work with add(), which should be /// threadsafe. - class Executor : boost::noncopyable { + class Executor { public: virtual ~Executor() = default; -- 2.34.1