value_type&& get() {
if (core_type::available()) {
return core_type::get();
- } else {
- // destined to wait!
- auto interruption_condition = interrupt_cond<InterruptCond>.interrupt_cond;
- INTR_FUT_DEBUG(
- "interruptible_future_detail::get() waiting, interrupt_cond: {},{}",
- (void*)interrupt_cond<InterruptCond>.interrupt_cond.get(),
- typeid(InterruptCond).name());
- interrupt_cond<InterruptCond>.reset();
- try {
- auto&& value = core_type::get();
- interrupt_cond<InterruptCond>.set(interruption_condition);
- INTR_FUT_DEBUG(
- "interruptible_future_detail::get() got, interrupt_cond: {},{}",
- (void*)interrupt_cond<InterruptCond>.interrupt_cond.get(),
- typeid(InterruptCond).name());
- return std::move(value);
- } catch (std::exception &e) {
- interrupt_cond<InterruptCond>.set(interruption_condition);
- INTR_FUT_DEBUG(
- "interruptible_future_detail::get() error {}, interrupt_cond: {},{}",
- e,
- (void*)interrupt_cond<InterruptCond>.interrupt_cond.get(),
- typeid(InterruptCond).name());
- throw;
+ }
+ // destined to wait!
+ auto interruption_condition = interrupt_cond<InterruptCond>.interrupt_cond;
+ INTR_FUT_DEBUG(
+ "interruptible_future_detail::get() waiting, interrupt_cond: {},{}",
+ (void*)interrupt_cond<InterruptCond>.interrupt_cond.get(),
+ typeid(InterruptCond).name());
+ interrupt_cond<InterruptCond>.reset();
+ try {
+ auto&& value = core_type::get();
+ auto ifut = interruption_condition->template may_interrupt<seastar::future<>>();
+ if (ifut) {
+ std::rethrow_exception(ifut->get_exception());
}
+
+ interrupt_cond<InterruptCond>.set(interruption_condition);
+ INTR_FUT_DEBUG(
+ "interruptible_future_detail::get() got, interrupt_cond: {},{}",
+ (void*)interrupt_cond<InterruptCond>.interrupt_cond.get(),
+ typeid(InterruptCond).name());
+ return std::move(value);
+ } catch (std::exception &e) {
+ interrupt_cond<InterruptCond>.set(interruption_condition);
+ INTR_FUT_DEBUG(
+ "interruptible_future_detail::get() error {}, interrupt_cond: {},{}",
+ e,
+ (void*)interrupt_cond<InterruptCond>.interrupt_cond.get(),
+ typeid(InterruptCond).name());
+ throw;
}
}
static decltype(auto) green_get(FutureT&& fut) {
if (fut.available()) {
return fut.get();
- } else {
- // destined to wait!
- auto interruption_condition = interrupt_cond<InterruptCond>.interrupt_cond;
+ }
+ // destined to wait!
+ auto interruption_condition = interrupt_cond<InterruptCond>.interrupt_cond;
+ INTR_FUT_DEBUG(
+ "green_get() waiting, interrupt_cond: {},{}",
+ (void*)interrupt_cond<InterruptCond>.interrupt_cond.get(),
+ typeid(InterruptCond).name());
+ interrupt_cond<InterruptCond>.reset();
+ try {
+ auto&& value = fut.get();
+ auto ifut = interruption_condition->template may_interrupt<future<void>>();
+ if (ifut) {
+ std::rethrow_exception(ifut->get_exception());
+ }
+ interrupt_cond<InterruptCond>.set(interruption_condition);
INTR_FUT_DEBUG(
- "green_get() waiting, interrupt_cond: {},{}",
+ "green_get() got, interrupt_cond: {},{}",
(void*)interrupt_cond<InterruptCond>.interrupt_cond.get(),
typeid(InterruptCond).name());
- interrupt_cond<InterruptCond>.reset();
- try {
- auto&& value = fut.get();
- interrupt_cond<InterruptCond>.set(interruption_condition);
- INTR_FUT_DEBUG(
- "green_get() got, interrupt_cond: {},{}",
- (void*)interrupt_cond<InterruptCond>.interrupt_cond.get(),
- typeid(InterruptCond).name());
- return std::move(value);
- } catch (std::exception &e) {
- interrupt_cond<InterruptCond>.set(interruption_condition);
- INTR_FUT_DEBUG(
- "green_get() error {}, interrupt_cond: {},{}",
- e,
- (void*)interrupt_cond<InterruptCond>.interrupt_cond.get(),
- typeid(InterruptCond).name());
- throw;
- }
+ return std::move(value);
+ } catch (std::exception &e) {
+ interrupt_cond<InterruptCond>.set(interruption_condition);
+ INTR_FUT_DEBUG(
+ "green_get() error {}, interrupt_cond: {},{}",
+ e,
+ (void*)interrupt_cond<InterruptCond>.interrupt_cond.get(),
+ typeid(InterruptCond).name());
+ throw;
}
}
typeid(InterruptCond).name());
throw;
}
+ auto &interrupt_condition = *interrupt_cond<InterruptCond>.interrupt_cond;
+ auto fut = interrupt_condition.template may_interrupt<future<void>>();
+ if (fut) {
+ std::rethrow_exception(fut->get_exception());
+ }
}
static void maybe_yield() {
typeid(InterruptCond).name());
throw;
}
+ auto &interrupt_condition = *interrupt_cond<InterruptCond>.interrupt_cond;
+ auto fut = interrupt_condition.template may_interrupt<future<void>>();
+ if (fut) {
+ std::rethrow_exception(fut->get_exception());
+ }
}
}
};