mirror of
https://github.com/Naios/continuable.git
synced 2025-12-06 16:56:44 +08:00
more
This commit is contained in:
parent
bf1ac9daee
commit
ddd5b0a0a6
@ -35,6 +35,11 @@
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#if !defined(CONTINUABLE_WITH_CUSTOM_ERROR_TYPE) && \
|
||||
!defined(CONTINUABLE_WITH_NO_EXCEPTIONS)
|
||||
#include <exception>
|
||||
#endif
|
||||
|
||||
#include <continuable/detail/api.hpp>
|
||||
#include <continuable/detail/hints.hpp>
|
||||
#include <continuable/detail/traits.hpp>
|
||||
@ -235,8 +240,18 @@ template <typename Invoker, typename... Args>
|
||||
void packed_dispatch(types::this_thread_executor_tag, Invoker&& invoker,
|
||||
Args&&... args) {
|
||||
|
||||
!defined(CONTINUABLE_WITH_NO_EXCEPTIONS)
|
||||
// Make it possible to throw exceptions from continuations chained
|
||||
// through `then` or `flow`.
|
||||
try {
|
||||
std::forward<Invoker>(invoker)(std::forward<Args>(args)...);
|
||||
} catch (...) {
|
||||
std::current_exception();
|
||||
}
|
||||
#else
|
||||
// Invoke the callback with the decorated invoker immediately
|
||||
std::forward<Invoker>(invoker)(std::forward<Args>(args)...);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Invoke the callback through the given executor
|
||||
|
||||
@ -128,7 +128,7 @@ auto as_future(continuable_base<Data, Annotation>&& continuable) {
|
||||
auto future = callback.get_future();
|
||||
|
||||
// Dispatch the continuation with the promise resolving callback
|
||||
std::move(continuable).then(std::move(callback)).done();
|
||||
std::move(continuable).flow(std::move(callback)).done();
|
||||
|
||||
return future;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user