mirror of
https://github.com/Naios/continuable.git
synced 2025-12-06 16:56:44 +08:00
Rename set_error -> set_exception
* In order to move closer to the standard
This commit is contained in:
parent
37c70c3365
commit
7d9198b5cc
@ -37,12 +37,14 @@
|
||||
#include <continuable/detail/api.hpp>
|
||||
#include <continuable/detail/hints.hpp>
|
||||
#include <continuable/detail/types.hpp>
|
||||
#include <continuable/detail/util.hpp>
|
||||
|
||||
namespace cti {
|
||||
template <typename Data, typename Hint>
|
||||
class promise_base;
|
||||
template <typename Data, typename... Args>
|
||||
class promise_base<Data, detail::hints::signature_hint_tag<Args...>> {
|
||||
class promise_base<Data, detail::hints::signature_hint_tag<Args...>>
|
||||
: detail::util::non_copyable {
|
||||
/// \cond false
|
||||
// The callback type
|
||||
Data data_;
|
||||
@ -59,27 +61,19 @@ public:
|
||||
promise_base(OData&& data) : data_(std::forward<OData>(data)) {
|
||||
}
|
||||
|
||||
/// \cond false
|
||||
promise_base(promise_base&&) = default;
|
||||
promise_base(promise_base const&) = default;
|
||||
|
||||
promise_base& operator=(promise_base&&) = default;
|
||||
promise_base& operator=(promise_base const&) = default;
|
||||
/// \endcond
|
||||
/// Resolves the continuation with the given values
|
||||
void operator()(Args... args) {
|
||||
data_(std::move(args)...);
|
||||
}
|
||||
|
||||
/// Resolves the continuation with the given values
|
||||
void set_value(Args... args) {
|
||||
data_(std::move(args)...);
|
||||
}
|
||||
|
||||
/// Resolves the continuation with the given values
|
||||
void operator()(Args... args) {
|
||||
data_(std::move(args)...);
|
||||
}
|
||||
|
||||
/// Resolves the continuation with the given error variable.
|
||||
void set_error(detail::types::error_type error) {
|
||||
data_(detail::types::dispatch_error_tag{}, std::move(error));
|
||||
/// Resolves the continuation with the given exception
|
||||
void set_exception(detail::types::error_type exception) {
|
||||
data_(detail::types::dispatch_error_tag{}, std::move(exception));
|
||||
}
|
||||
};
|
||||
} // namespace cti
|
||||
|
||||
@ -309,7 +309,7 @@ struct result_callback<hints::signature_hint_tag<Args...>, Callback, Executor,
|
||||
}
|
||||
|
||||
/// Resolves the continuation with the given error variable.
|
||||
void set_error(types::error_type error) {
|
||||
void set_exception(types::error_type error) {
|
||||
std::move(next_callback_)(types::dispatch_error_tag{}, std::move(error));
|
||||
}
|
||||
};
|
||||
@ -348,7 +348,7 @@ struct error_callback<hints::signature_hint_tag<Args...>, Callback, Executor,
|
||||
}
|
||||
|
||||
/// Resolves the continuation with the given error variable.
|
||||
void set_error(types::error_type error) {
|
||||
void set_exception(types::error_type error) {
|
||||
std::move(next_callback_)(types::dispatch_error_tag{}, std::move(error));
|
||||
}
|
||||
};
|
||||
@ -364,7 +364,7 @@ struct empty_callback {
|
||||
void set_value(Args... /*error*/) {
|
||||
}
|
||||
|
||||
void set_error(types::error_type /*error*/) {
|
||||
void set_exception(types::error_type /*error*/) {
|
||||
}
|
||||
};
|
||||
} // namespace callbacks
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
|
||||
cti::continuable<std::string> http_request(std::string url) {
|
||||
return [](cti::promise<std::string> promise) {
|
||||
promise.set_error(nullptr);
|
||||
promise.set_exception(nullptr);
|
||||
promise.set_value("");
|
||||
promise("");
|
||||
};
|
||||
@ -34,7 +34,7 @@ cti::continuable<std::string> http_request(std::string url) {
|
||||
|
||||
auto http_request2(std::string url) {
|
||||
return cti::make_continuable<std::string>([](auto&& promise) {
|
||||
promise.set_error(nullptr);
|
||||
promise.set_exception(nullptr);
|
||||
promise.set_value("");
|
||||
promise("");
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user