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/api.hpp>
|
||||||
#include <continuable/detail/hints.hpp>
|
#include <continuable/detail/hints.hpp>
|
||||||
#include <continuable/detail/types.hpp>
|
#include <continuable/detail/types.hpp>
|
||||||
|
#include <continuable/detail/util.hpp>
|
||||||
|
|
||||||
namespace cti {
|
namespace cti {
|
||||||
template <typename Data, typename Hint>
|
template <typename Data, typename Hint>
|
||||||
class promise_base;
|
class promise_base;
|
||||||
template <typename Data, typename... Args>
|
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
|
/// \cond false
|
||||||
// The callback type
|
// The callback type
|
||||||
Data data_;
|
Data data_;
|
||||||
@ -59,27 +61,19 @@ public:
|
|||||||
promise_base(OData&& data) : data_(std::forward<OData>(data)) {
|
promise_base(OData&& data) : data_(std::forward<OData>(data)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \cond false
|
/// Resolves the continuation with the given values
|
||||||
promise_base(promise_base&&) = default;
|
void operator()(Args... args) {
|
||||||
promise_base(promise_base const&) = default;
|
data_(std::move(args)...);
|
||||||
|
}
|
||||||
promise_base& operator=(promise_base&&) = default;
|
|
||||||
promise_base& operator=(promise_base const&) = default;
|
|
||||||
/// \endcond
|
|
||||||
|
|
||||||
/// Resolves the continuation with the given values
|
/// Resolves the continuation with the given values
|
||||||
void set_value(Args... args) {
|
void set_value(Args... args) {
|
||||||
data_(std::move(args)...);
|
data_(std::move(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resolves the continuation with the given values
|
/// Resolves the continuation with the given exception
|
||||||
void operator()(Args... args) {
|
void set_exception(detail::types::error_type exception) {
|
||||||
data_(std::move(args)...);
|
data_(detail::types::dispatch_error_tag{}, std::move(exception));
|
||||||
}
|
|
||||||
|
|
||||||
/// 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));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace cti
|
} // namespace cti
|
||||||
|
|||||||
@ -309,7 +309,7 @@ struct result_callback<hints::signature_hint_tag<Args...>, Callback, Executor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Resolves the continuation with the given error variable.
|
/// 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));
|
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.
|
/// 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));
|
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_value(Args... /*error*/) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_error(types::error_type /*error*/) {
|
void set_exception(types::error_type /*error*/) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace callbacks
|
} // namespace callbacks
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
cti::continuable<std::string> http_request(std::string url) {
|
cti::continuable<std::string> http_request(std::string url) {
|
||||||
return [](cti::promise<std::string> promise) {
|
return [](cti::promise<std::string> promise) {
|
||||||
promise.set_error(nullptr);
|
promise.set_exception(nullptr);
|
||||||
promise.set_value("");
|
promise.set_value("");
|
||||||
promise("");
|
promise("");
|
||||||
};
|
};
|
||||||
@ -34,7 +34,7 @@ cti::continuable<std::string> http_request(std::string url) {
|
|||||||
|
|
||||||
auto http_request2(std::string url) {
|
auto http_request2(std::string url) {
|
||||||
return cti::make_continuable<std::string>([](auto&& promise) {
|
return cti::make_continuable<std::string>([](auto&& promise) {
|
||||||
promise.set_error(nullptr);
|
promise.set_exception(nullptr);
|
||||||
promise.set_value("");
|
promise.set_value("");
|
||||||
promise("");
|
promise("");
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user