#include <folly/io/async/EventBase.h>
+#include <folly/Baton.h>
#include <folly/ThreadName.h>
#include <folly/io/async/NotificationQueue.h>
return true;
}
+bool EventBase::runInEventBaseThreadAndWait(void (*fn)(void*), void* arg) {
+ if (inRunningEventBaseThread()) {
+ LOG(ERROR) << "EventBase " << this << ": Waiting in the event loop is not "
+ << "allowed";
+ return false;
+ }
+
+ Baton<> ready;
+ runInEventBaseThread([&] {
+ fn(arg);
+ ready.post();
+ });
+ ready.wait();
+
+ return true;
+}
+
+bool EventBase::runInEventBaseThreadAndWait(const Cob& fn) {
+ if (inRunningEventBaseThread()) {
+ LOG(ERROR) << "EventBase " << this << ": Waiting in the event loop is not "
+ << "allowed";
+ return false;
+ }
+
+ Baton<> ready;
+ runInEventBaseThread([&] {
+ fn();
+ ready.post();
+ });
+ ready.wait();
+
+ return true;
+}
+
bool EventBase::runAfterDelay(const Cob& cob,
int milliseconds,
TimeoutManager::InternalEnum in) {