#include <folly/io/async/EventBase.h>
#include <folly/SocketAddress.h>
-#include <boost/thread/barrier.hpp>
-
#include <folly/io/IOBuf.h>
#include <folly/portability/GTest.h>
evb.loopForever();
});
- auto r = std::make_shared<boost::barrier>(2);
- evb.runInEventBaseThread([r] () {
- r->wait();
- });
- r->wait();
+ evb.waitUntilRunning();
socket_->addListener(&evb, &acceptors_[i]);
threads_.emplace_back(std::move(t));
TEST(AsyncSocketTest, PingPong) {
folly::EventBase sevb;
UDPServer server(&sevb, folly::SocketAddress("127.0.0.1", 0), 4);
- boost::barrier barrier(2);
// Start event loop in a separate thread
auto serverThread = std::thread([&sevb] () {
});
// Wait for event loop to start
- sevb.runInEventBaseThread([&] () { barrier.wait(); });
- barrier.wait();
+ sevb.waitUntilRunning();
// Start the server
- sevb.runInEventBaseThread([&] () { server.start(); barrier.wait(); });
- barrier.wait();
+ sevb.runInEventBaseThreadAndWait([&]() { server.start(); });
folly::EventBase cevb;
UDPClient client(&cevb);
});
// Wait for event loop to start
- cevb.runInEventBaseThread([&] () { barrier.wait(); });
- barrier.wait();
+ cevb.waitUntilRunning();
// Send ping
cevb.runInEventBaseThread([&] () { client.start(server.address(), 1000); });