Commit bf590e16 authored by Hannes Roth's avatar Hannes Roth Committed by Sara Golemon

(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
parent 8e845aca
......@@ -414,3 +414,30 @@ TEST(Via, viaRaces) {
t1.join();
t2.join();
}
TEST(Future, callbackRace) {
ThreadExecutor x;
auto fn = [&x]{
auto promises = std::make_shared<std::vector<Promise<void>>>(4);
std::vector<Future<void>> futures;
for (auto& p : *promises) {
futures.emplace_back(
p.getFuture()
.via(&x)
.then([](Try<void>&&){}));
}
x.waitForStartup();
x.add([promises]{
for (auto& p : *promises) {
p.setValue();
}
});
return collectAll(futures);
};
fn().wait();
}
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