/// time there won't be any problems.
template<typename T>
class Core {
+ static_assert(!std::is_void<T>::value,
+ "void futures are not supported. Use Unit instead.");
public:
/// This must be heap-constructed. There's probably a way to enforce that in
/// code but since this is just internal detail code and I don't know how
}
void doCallback() {
- RequestContext::setContext(context_);
-
Executor* x = executor_;
int8_t priority;
if (x) {
if (LIKELY(x->getNumPriorities() == 1)) {
x->add([this]() mutable {
SCOPE_EXIT { detachOne(); };
+ RequestContext::setContext(context_);
callback_(std::move(*result_));
});
} else {
x->addWithPriority([this]() mutable {
SCOPE_EXIT { detachOne(); };
+ RequestContext::setContext(context_);
callback_(std::move(*result_));
}, priority);
}
} catch (...) {
--attached_; // Account for extra ++attached_ before try
+ RequestContext::setContext(context_);
result_ = Try<T>(exception_wrapper(std::current_exception()));
callback_(std::move(*result_));
}
} else {
+ RequestContext::setContext(context_);
callback_(std::move(*result_));
}
}