join
authorHans Fugal <fugalh@fb.com>
Tue, 6 Jan 2015 20:22:52 +0000 (12:22 -0800)
committerViswanath Sivakumar <viswanath@fb.com>
Tue, 13 Jan 2015 19:01:04 +0000 (11:01 -0800)
Summary:
Fixes T5922800
(I think)

Test Plan:
TBH I don't know why detaching a temporary thread variable might cause the program to abort but this seems to be the most likely cause so I'm making this change and we'll see in a day or two if it fixes it.

The test still passes and doesn't hang

Reviewed By: davejwatson@fb.com

Subscribers: fugalh, exa, folly-diffs@

FB internal diff: D1764374

Tasks: 5922800

Signature: t1:1764374:1420485233:2e4c81776ef6b6bdae18fbf2e99f0deea37b7879

folly/wangle/futures/test/TimekeeperTest.cpp

index 6edbb91de6c9640e5b8419708dc5b46dca16ddf0..49f8b0c992713900b6774a701da94c53b413804d 100644 (file)
@@ -58,7 +58,7 @@ TEST(Timekeeper, futureGet) {
 
 TEST(Timekeeper, futureGetBeforeTimeout) {
   Promise<int> p;
-  std::thread([&]{ p.setValue(42); }).detach();
+  auto t = std::thread([&]{ p.setValue(42); });
   // Technically this is a race and if the test server is REALLY overloaded
   // and it takes more than a second to do that thread it could be flaky. But
   // I want a low timeout (in human terms) so if this regresses and someone
@@ -66,6 +66,7 @@ TEST(Timekeeper, futureGetBeforeTimeout) {
   // blocked, and get a useful error message instead. If it does get flaky,
   // empirically increase the timeout to the point where it's very improbable.
   EXPECT_EQ(42, p.getFuture().get(seconds(2)));
+  t.join();
 }
 
 TEST(Timekeeper, futureGetTimeout) {