// wrap these so we can move them into the lambda
folly::MoveWrapper<Promise<B>> p;
+ p->setInterruptHandler(core_->getInterruptHandler());
folly::MoveWrapper<F> funcm(std::forward<F>(func));
// grab the Future now before we lose our handle on the Promise
}
}
+ std::function<void(exception_wrapper const&)> getInterruptHandler() {
+ folly::MSLGuard guard(interruptLock_);
+ return interruptHandler_;
+ }
+
/// Call only from Promise thread
void setInterruptHandler(std::function<void(exception_wrapper const&)> fn) {
folly::MSLGuard guard(interruptLock_);
f.cancel();
}
+TEST(Timekeeper, chainedInterruptTest) {
+ bool test = false;
+ auto f = futures::sleep(Duration(100)).then([&](){
+ test = true;
+ });
+ f.cancel();
+ f.wait();
+ EXPECT_FALSE(test);
+}
// TODO(5921764)
/*
TEST(Timekeeper, onTimeoutPropagates) {