From: Andrey Ignatov Date: Tue, 20 Sep 2016 19:14:33 +0000 (-0700) Subject: Remove boost::barrier from AsyncUDPSocketTest. X-Git-Tag: v2016.09.26.00~11 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c821d1297ed95adc94c1ad38856dd0f0a3ef300a;p=folly.git 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 --- diff --git a/folly/io/async/test/AsyncUDPSocketTest.cpp b/folly/io/async/test/AsyncUDPSocketTest.cpp index acaf76b4..eff57428 100644 --- a/folly/io/async/test/AsyncUDPSocketTest.cpp +++ b/folly/io/async/test/AsyncUDPSocketTest.cpp @@ -20,8 +20,6 @@ #include #include -#include - #include #include @@ -110,11 +108,7 @@ class UDPServer { evb.loopForever(); }); - auto r = std::make_shared(2); - evb.runInEventBaseThread([r] () { - r->wait(); - }); - r->wait(); + evb.waitUntilRunning(); socket_->addListener(&evb, &acceptors_[i]); threads_.emplace_back(std::move(t)); @@ -255,7 +249,6 @@ class UDPClient 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] () { @@ -263,12 +256,10 @@ TEST(AsyncSocketTest, PingPong) { }); // 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); @@ -279,8 +270,7 @@ TEST(AsyncSocketTest, PingPong) { }); // Wait for event loop to start - cevb.runInEventBaseThread([&] () { barrier.wait(); }); - barrier.wait(); + cevb.waitUntilRunning(); // Send ping cevb.runInEventBaseThread([&] () { client.start(server.address(), 1000); });