EventBase::runImediatelyOrRunInEventBaseThreadAndWait.
[folly.git] / folly / io / async / EventBase.cpp
index 8bc09523d05b1fba5f608df5abfefe4bc7f18fe3..5ff171eb2c3f7c043ceb04ee03b7df8793cf4e42 100644 (file)
@@ -610,6 +610,15 @@ bool EventBase::runInEventBaseThreadAndWait(const Cob& fn) {
   return true;
 }
 
+bool EventBase::runImmediatelyOrRunInEventBaseThreadAndWait(const Cob& fn) {
+  if (inRunningEventBaseThread()) {
+    fn();
+    return true;
+  } else {
+    return runInEventBaseThreadAndWait(fn);
+  }
+}
+
 void EventBase::runAfterDelay(const Cob& cob,
                               int milliseconds,
                               TimeoutManager::InternalEnum in) {