From 33191ca312b82f0df4674e0bb5efd9aa0b895ab8 Mon Sep 17 00:00:00 2001 From: James Sedgwick Date: Thu, 11 Jun 2015 10:41:43 -0700 Subject: [PATCH] wangle::getEventBase() Summary: this is going to be a really common pattern, so I'm providing a shortcut Reviewed By: @fugalh Differential Revision: D2146008 --- folly/wangle/concurrent/GlobalExecutor.cpp | 4 ++++ folly/wangle/concurrent/GlobalExecutor.h | 3 +++ 2 files changed, 7 insertions(+) diff --git a/folly/wangle/concurrent/GlobalExecutor.cpp b/folly/wangle/concurrent/GlobalExecutor.cpp index 36a82155..9d6aca40 100644 --- a/folly/wangle/concurrent/GlobalExecutor.cpp +++ b/folly/wangle/concurrent/GlobalExecutor.cpp @@ -110,6 +110,10 @@ std::shared_ptr getIOExecutor() { globalIOExecutorLock); } +EventBase* getEventBase() { + return getIOExecutor()->getEventBase(); +} + void setIOExecutor(std::shared_ptr executor) { setExecutor( std::move(executor), diff --git a/folly/wangle/concurrent/GlobalExecutor.h b/folly/wangle/concurrent/GlobalExecutor.h index fa7d06c6..d85b180d 100644 --- a/folly/wangle/concurrent/GlobalExecutor.h +++ b/folly/wangle/concurrent/GlobalExecutor.h @@ -39,6 +39,9 @@ void setCPUExecutor(std::shared_ptr executor); // one or more EventBases. std::shared_ptr getIOExecutor(); +// Retrieve an event base from the global IOExecutor +EventBase* getEventBase(); + // Set an IOExecutor to be the global IOExecutor which will be returned by // subsequent calls to getIOExecutor(). Takes a non-owning (weak) reference. void setIOExecutor(std::shared_ptr executor); -- 2.34.1