From bf590e16a063840e2691f775da187be04cb7bd2f Mon Sep 17 00:00:00 2001 From: Hannes Roth Date: Wed, 10 Jun 2015 09:06:50 -0700 Subject: [PATCH] (Wangle) Re-add race test Summary: I figured this test would be useless since it tests a check added before everything was converted to FSM. But since it appears to fail on Mac OS X, it might be useful to have after all. Reviewed By: @fugalh Differential Revision: D2143500 --- folly/futures/test/ViaTest.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/folly/futures/test/ViaTest.cpp b/folly/futures/test/ViaTest.cpp index 9acac1bc..72b2e1e8 100644 --- a/folly/futures/test/ViaTest.cpp +++ b/folly/futures/test/ViaTest.cpp @@ -414,3 +414,30 @@ TEST(Via, viaRaces) { t1.join(); t2.join(); } + +TEST(Future, callbackRace) { + ThreadExecutor x; + + auto fn = [&x]{ + auto promises = std::make_shared>>(4); + std::vector> futures; + + for (auto& p : *promises) { + futures.emplace_back( + p.getFuture() + .via(&x) + .then([](Try&&){})); + } + + x.waitForStartup(); + x.add([promises]{ + for (auto& p : *promises) { + p.setValue(); + } + }); + + return collectAll(futures); + }; + + fn().wait(); +} -- 2.34.1