return true;
return false;
}
+
+ void set_interrupt() {
+ interrupt = true;
+ }
private:
bool interrupt = false;
};
return fut;
}, [](std::exception_ptr) {}, false).get();
});
+
+}
+
+TEST_F(seastar_test_suite_t, interruptible_yield)
+{
+ using interruptor =
+ interruptible::interruptor<TestInterruptCondition>;
+
+ run_async([] {
+ bool interrupted = false;
+ auto fut = interruptor::with_interruption([] {
+ return interruptor::async([] {
+ interruptible::interrupt_cond<
+ TestInterruptCondition>.interrupt_cond->set_interrupt();
+ interruptor::yield();
+ // the execution should be interrupted, the run should
+ // never reach here.
+ ceph_abort();
+ });
+ }, [&interrupted](std::exception_ptr) {
+ std::cout << "interrupted" << std::endl;
+ interrupted = true;
+ }, false);
+ fut.wait();
+ ceph_assert(interrupted);
+
+ interrupted = false;
+ fut = interruptor::with_interruption([] {
+ return interruptor::async([] {
+ interruptible::interrupt_cond<
+ TestInterruptCondition>.interrupt_cond->set_interrupt();
+ interruptor::green_get(seastar::yield());
+ // the execution should be interrupted, the run should
+ // never reach here.
+ ceph_abort();
+ });
+ }, [&interrupted](std::exception_ptr) {
+ std::cout << "interrupted" << std::endl;
+ interrupted = true;
+ }, false);
+ fut.wait();
+ ceph_assert(interrupted);
+
+ interrupted = false;
+ fut = interruptor::with_interruption([] {
+ return interruptor::async([] {
+ interruptible::interrupt_cond<
+ TestInterruptCondition>.interrupt_cond->set_interrupt();
+ interruptor::make_interruptible(seastar::yield()).get();
+ // the execution should be interrupted, the run should
+ // never reach here.
+ ceph_abort();
+ });
+ }, [&interrupted](std::exception_ptr) {
+ std::cout << "interrupted" << std::endl;
+ interrupted = true;
+ }, false);
+ fut.wait();
+ ceph_assert(interrupted);
+ });
}
TEST_F(seastar_test_suite_t, DISABLED_nested_interruptors)