From bb8907beb9f7c3b797e48e1149428768a4f3517e Mon Sep 17 00:00:00 2001 From: James Sedgwick Date: Fri, 26 Sep 2014 12:17:01 -0700 Subject: [PATCH] fix future executor test Summary: This should be the last test abusing sleeps. Test Plan: ran Reviewed By: hannesr@fb.com Subscribers: fugalh, njormrod FB internal diff: D1580830 Tasks: 5225808 --- .../wangle/concurrent/test/ThreadPoolExecutorTest.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/folly/experimental/wangle/concurrent/test/ThreadPoolExecutorTest.cpp b/folly/experimental/wangle/concurrent/test/ThreadPoolExecutorTest.cpp index 00d5ccac..e3336615 100644 --- a/folly/experimental/wangle/concurrent/test/ThreadPoolExecutorTest.cpp +++ b/folly/experimental/wangle/concurrent/test/ThreadPoolExecutorTest.cpp @@ -249,7 +249,8 @@ static void futureExecutor() { EXPECT_THROW(t.value(), std::runtime_error); }); // Test doing actual async work - fe.addFuture([] () { + folly::Baton<> baton; + fe.addFuture([&] () { auto p = std::make_shared>(); std::thread t([p](){ burnMs(10)(); @@ -260,8 +261,9 @@ static void futureExecutor() { }).then([&] (Try&& t) { EXPECT_EQ(42, t.value()); c++; + baton.post(); }); - burnMs(15)(); // Sleep long enough for the promise to be fulfilled + baton.wait(); fe.join(); EXPECT_EQ(6, c); } -- 2.34.1