From: James Sedgwick Date: Fri, 26 Sep 2014 19:17:01 +0000 (-0700) Subject: fix future executor test X-Git-Tag: v0.22.0~318 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=bb8907beb9f7c3b797e48e1149428768a4f3517e;p=folly.git 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 --- 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); }