wangle::getEventBase()
authorJames Sedgwick <jsedgwick@fb.com>
Thu, 11 Jun 2015 17:41:43 +0000 (10:41 -0700)
committerSara Golemon <sgolemon@fb.com>
Thu, 11 Jun 2015 20:15:12 +0000 (13:15 -0700)
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
folly/wangle/concurrent/GlobalExecutor.h

index 36a82155ee1252a29111d05b8cd5f1464692c307..9d6aca40066610c5baf61262b67637ab9952303b 100644 (file)
@@ -110,6 +110,10 @@ std::shared_ptr<IOExecutor> getIOExecutor() {
       globalIOExecutorLock);
 }
 
+EventBase* getEventBase() {
+  return getIOExecutor()->getEventBase();
+}
+
 void setIOExecutor(std::shared_ptr<IOExecutor> executor) {
   setExecutor(
       std::move(executor),
index fa7d06c6d5f0fd923d090a8f3a317a2029b9e618..d85b180db8aab0d88c6e33c849fc77774d13311d 100644 (file)
@@ -39,6 +39,9 @@ void setCPUExecutor(std::shared_ptr<Executor> executor);
 // one or more EventBases.
 std::shared_ptr<IOExecutor> 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<IOExecutor> executor);