std::atomic<bool> token {false};
};
+ if (this->isReady()) {
+ return std::move(*this);
+ }
+
std::shared_ptr<Timekeeper> tks;
if (!tk) {
tks = folly::detail::getTimekeeperSingleton();
EXPECT_TRUE(flag);
}
+TEST(Timekeeper, onTimeoutComplete) {
+ bool flag = false;
+ makeFuture(42)
+ .onTimeout(zero_ms, [&]{ flag = true; return -1; })
+ .get();
+ EXPECT_FALSE(flag);
+}
+
TEST(Timekeeper, onTimeoutReturnsFuture) {
bool flag = false;
makeFuture(42).delayed(10 * one_ms)
std::atomic<int> count{0};
};
- auto f = makeFuture();
+ Promise<Unit> p;
ExecutorTester tester;
- f.via(&tester).within(one_ms).then([&](){}).wait();
+ auto f = p.getFuture().via(&tester).within(one_ms).then([&](){});
+ p.setValue();
+ f.wait();
EXPECT_EQ(2, tester.count);
}