Commit c821d129 authored by Andrey Ignatov's avatar Andrey Ignatov Committed by Facebook Github Bot 7

Remove boost::barrier from AsyncUDPSocketTest.

Summary:
`EventBase` has its own methods to wait till it's ready so we can avoid using
barriers and remove boost dependency.

Reviewed By: mzlee

Differential Revision: D3894408

fbshipit-source-id: f050a982c98c4f672cf295845115686c95fc7919
parent 691cd11c
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include <folly/io/async/EventBase.h> #include <folly/io/async/EventBase.h>
#include <folly/SocketAddress.h> #include <folly/SocketAddress.h>
#include <boost/thread/barrier.hpp>
#include <folly/io/IOBuf.h> #include <folly/io/IOBuf.h>
#include <folly/portability/GTest.h> #include <folly/portability/GTest.h>
...@@ -110,11 +108,7 @@ class UDPServer { ...@@ -110,11 +108,7 @@ class UDPServer {
evb.loopForever(); evb.loopForever();
}); });
auto r = std::make_shared<boost::barrier>(2); evb.waitUntilRunning();
evb.runInEventBaseThread([r] () {
r->wait();
});
r->wait();
socket_->addListener(&evb, &acceptors_[i]); socket_->addListener(&evb, &acceptors_[i]);
threads_.emplace_back(std::move(t)); threads_.emplace_back(std::move(t));
...@@ -255,7 +249,6 @@ class UDPClient ...@@ -255,7 +249,6 @@ class UDPClient
TEST(AsyncSocketTest, PingPong) { TEST(AsyncSocketTest, PingPong) {
folly::EventBase sevb; folly::EventBase sevb;
UDPServer server(&sevb, folly::SocketAddress("127.0.0.1", 0), 4); UDPServer server(&sevb, folly::SocketAddress("127.0.0.1", 0), 4);
boost::barrier barrier(2);
// Start event loop in a separate thread // Start event loop in a separate thread
auto serverThread = std::thread([&sevb] () { auto serverThread = std::thread([&sevb] () {
...@@ -263,12 +256,10 @@ TEST(AsyncSocketTest, PingPong) { ...@@ -263,12 +256,10 @@ TEST(AsyncSocketTest, PingPong) {
}); });
// Wait for event loop to start // Wait for event loop to start
sevb.runInEventBaseThread([&] () { barrier.wait(); }); sevb.waitUntilRunning();
barrier.wait();
// Start the server // Start the server
sevb.runInEventBaseThread([&] () { server.start(); barrier.wait(); }); sevb.runInEventBaseThreadAndWait([&]() { server.start(); });
barrier.wait();
folly::EventBase cevb; folly::EventBase cevb;
UDPClient client(&cevb); UDPClient client(&cevb);
...@@ -279,8 +270,7 @@ TEST(AsyncSocketTest, PingPong) { ...@@ -279,8 +270,7 @@ TEST(AsyncSocketTest, PingPong) {
}); });
// Wait for event loop to start // Wait for event loop to start
cevb.runInEventBaseThread([&] () { barrier.wait(); }); cevb.waitUntilRunning();
barrier.wait();
// Send ping // Send ping
cevb.runInEventBaseThread([&] () { client.start(server.address(), 1000); }); cevb.runInEventBaseThread([&] () { client.start(server.address(), 1000); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment