mirror of
https://github.com/Naios/continuable.git
synced 2025-12-07 01:06:44 +08:00
First attempt on making all promises non-copyable
* Fix CONTINUABLE_WITH_UNHANDLED_ERRORS when using the promise as real callback.
This commit is contained in:
parent
73c0b17962
commit
98aefb59d8
@ -392,9 +392,8 @@ struct callback_base<hints::signature_hint_tag<Args...>, HandleResults,
|
|||||||
proto::error_handler_base<
|
proto::error_handler_base<
|
||||||
HandleErrors,
|
HandleErrors,
|
||||||
callback_base<hints::signature_hint_tag<Args...>, HandleResults,
|
callback_base<hints::signature_hint_tag<Args...>, HandleResults,
|
||||||
HandleErrors, Callback, Executor, NextCallback>> {
|
HandleErrors, Callback, Executor, NextCallback>>,
|
||||||
|
util::non_copyable {
|
||||||
using CallbackT = Callback;
|
|
||||||
|
|
||||||
Callback callback_;
|
Callback callback_;
|
||||||
Executor executor_;
|
Executor executor_;
|
||||||
@ -445,16 +444,12 @@ auto make_callback(Callback&& callback, Executor&& executor,
|
|||||||
|
|
||||||
/// Once this was a workaround for GCC bug:
|
/// Once this was a workaround for GCC bug:
|
||||||
/// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64095
|
/// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64095
|
||||||
struct final_callback {
|
struct final_callback : util::non_copyable {
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
void operator()(Args... /*args*/) && {
|
void operator()(Args... /*args*/) && {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Args>
|
void operator()(types::dispatch_error_tag, types::error_type error) && {
|
||||||
void set_value(Args... /*args*/) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_exception(types::error_type error) {
|
|
||||||
(void)error;
|
(void)error;
|
||||||
#ifndef CONTINUABLE_WITH_UNHANDLED_ERRORS
|
#ifndef CONTINUABLE_WITH_UNHANDLED_ERRORS
|
||||||
// There were unhandled errors inside the asynchronous call chain!
|
// There were unhandled errors inside the asynchronous call chain!
|
||||||
@ -463,6 +458,15 @@ struct final_callback {
|
|||||||
util::trap();
|
util::trap();
|
||||||
#endif // CONTINUABLE_WITH_UNHANDLED_ERRORS
|
#endif // CONTINUABLE_WITH_UNHANDLED_ERRORS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename... Args>
|
||||||
|
void set_value(Args... args) {
|
||||||
|
std::move (*this)(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_exception(types::error_type error) {
|
||||||
|
std::move (*this)(types::dispatch_error_tag{}, std::move(error));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
} // namespace callbacks
|
} // namespace callbacks
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user