From: James Sedgwick Date: Thu, 11 Jun 2015 17:41:43 +0000 (-0700) Subject: wangle::getEventBase() X-Git-Tag: v0.47.0~42 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=33191ca312b82f0df4674e0bb5efd9aa0b895ab8;p=folly.git wangle::getEventBase() Summary: this is going to be a really common pattern, so I'm providing a shortcut Reviewed By: @fugalh Differential Revision: D2146008 --- 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);