#include <folly/io/async/EventBase.h>
-#include <folly/Baton.h>
#include <folly/ThreadName.h>
#include <folly/io/async/NotificationQueue.h>
#include <boost/static_assert.hpp>
+#include <condition_variable>
#include <fcntl.h>
+#include <mutex>
#include <pthread.h>
#include <unistd.h>
return false;
}
- Baton<> ready;
+ bool ready = false;
+ std::mutex m;
+ std::condition_variable cv;
runInEventBaseThread([&] {
+ SCOPE_EXIT {
+ std::unique_lock<std::mutex> l(m);
+ ready = true;
+ l.unlock();
+ cv.notify_one();
+ };
fn(arg);
- ready.post();
});
- ready.wait();
+ std::unique_lock<std::mutex> l(m);
+ cv.wait(l, [&] { return ready; });
return true;
}
return false;
}
- Baton<> ready;
+ bool ready = false;
+ std::mutex m;
+ std::condition_variable cv;
runInEventBaseThread([&] {
+ SCOPE_EXIT {
+ std::unique_lock<std::mutex> l(m);
+ ready = true;
+ l.unlock();
+ cv.notify_one();
+ };
fn();
- ready.post();
});
- ready.wait();
+ std::unique_lock<std::mutex> l(m);
+ cv.wait(l, [&] { return ready; });
return true;
}