Commit 3b0fb5d6 authored by Fengyang Wang's avatar Fengyang Wang Committed by Facebook Github Bot

Make EventBase subclass IOExecutor (as in docstring)

Summary: EventBase meets the definition of IOExecutor (it is an executor that "manages" at least one EventBase) and is already claimed to be one in the docstring.

Reviewed By: yfeldblum

Differential Revision: D7064481

fbshipit-source-id: 026e0e4c24d6fb15a32bc4772b35689f830ed944
parent b5fcc4f9
......@@ -746,5 +746,9 @@ VirtualEventBase& EventBase::getVirtualEventBase() {
return *virtualEventBase_;
}
EventBase* EventBase::getEventBase() {
return this;
}
constexpr std::chrono::milliseconds EventBase::SmoothLoopTime::buffer_interval_;
} // namespace folly
......@@ -39,6 +39,7 @@
#include <folly/Portability.h>
#include <folly/ScopeGuard.h>
#include <folly/executors/DrivableExecutor.h>
#include <folly/executors/IOExecutor.h>
#include <folly/executors/SequencedExecutor.h>
#include <folly/experimental/ExecutionObserver.h>
#include <folly/io/async/AsyncTimeout.h>
......@@ -128,6 +129,7 @@ class VirtualEventBase;
class EventBase : private boost::noncopyable,
public TimeoutManager,
public DrivableExecutor,
public IOExecutor,
public SequencedExecutor {
public:
using Func = folly::Function<void()>;
......@@ -659,6 +661,9 @@ class EventBase : private boost::noncopyable,
// don't need to manage the life time of the VirtualEventBase used.
folly::VirtualEventBase& getVirtualEventBase();
/// Implements the IOExecutor interface
EventBase* getEventBase() override;
protected:
void keepAliveAcquire() override {
if (inRunningEventBaseThread()) {
......
......@@ -1917,6 +1917,13 @@ TEST(EventBaseTest, DrivableExecutorTest) {
t.join();
}
TEST(EventBaseTest, IOExecutorTest) {
EventBase base;
// Ensure EventBase manages itself as an IOExecutor.
EXPECT_EQ(base.getEventBase(), &base);
}
TEST(EventBaseTest, RequestContextTest) {
EventBase evb;
auto defaultCtx = RequestContext::get();
......
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