mirror of
https://github.com/Naios/continuable.git
synced 2025-12-08 01:36:46 +08:00
Improve the documentation of promise and continuable
This commit is contained in:
parent
52cf1ab929
commit
b8b9f31024
@ -48,6 +48,7 @@
|
||||
namespace cti {
|
||||
template <typename Data, typename Annotation>
|
||||
class continuable_base {
|
||||
|
||||
/// \cond false
|
||||
template <typename, typename>
|
||||
friend class continuable_base;
|
||||
@ -601,6 +602,8 @@ auto make_continuable(Continuation&& continuation) {
|
||||
/// // Will receive errors and results
|
||||
/// continuable.then(my_callable{});
|
||||
/// ```
|
||||
///
|
||||
/// \since version 2.0.0
|
||||
using detail::types::dispatch_error_tag;
|
||||
|
||||
/// Represents the type that is used as error type
|
||||
@ -610,6 +613,8 @@ using detail::types::dispatch_error_tag;
|
||||
/// will be a `std::error_condition`.
|
||||
/// A custom error type may be set through
|
||||
/// defining `CONTINUABLE_WITH_CUSTOM_ERROR_TYPE`.
|
||||
///
|
||||
/// \since version 2.0.0
|
||||
using detail::types::error_type;
|
||||
|
||||
/// Connects the given continuables with an *all* logic.
|
||||
|
||||
@ -40,11 +40,19 @@
|
||||
#include <continuable/detail/util.hpp>
|
||||
|
||||
namespace cti {
|
||||
/// The promise_base makes it possible to resolve an asynchronous
|
||||
/// continuable through it's result or through an error type.
|
||||
///
|
||||
/// Use the promise type defined in `continuable/continuable.hpp`,
|
||||
/// in order to use this class.
|
||||
///
|
||||
/// \since version 2.0.0
|
||||
template <typename Data, typename Hint>
|
||||
class promise_base;
|
||||
template <typename Data, typename... Args>
|
||||
class promise_base<Data, detail::hints::signature_hint_tag<Args...>>
|
||||
: detail::util::non_copyable {
|
||||
|
||||
/// \cond false
|
||||
// The callback type
|
||||
Data data_;
|
||||
@ -62,21 +70,29 @@ public:
|
||||
}
|
||||
|
||||
/// Resolves the continuation with the given values
|
||||
///
|
||||
/// \since version 2.0.0
|
||||
void operator()(Args... args) {
|
||||
data_(std::move(args)...);
|
||||
}
|
||||
/// Resolves the continuation with the given exception
|
||||
///
|
||||
/// \since version 2.0.0
|
||||
void operator()(detail::types::dispatch_error_tag tag,
|
||||
detail::types::error_type exception) {
|
||||
data_(tag, std::move(exception));
|
||||
}
|
||||
|
||||
/// Resolves the continuation with the given values
|
||||
///
|
||||
/// \since version 2.0.0
|
||||
void set_value(Args... args) {
|
||||
data_(std::move(args)...);
|
||||
}
|
||||
|
||||
/// Resolves the continuation with the given exception
|
||||
///
|
||||
/// \since version 2.0.0
|
||||
void set_exception(detail::types::error_type exception) {
|
||||
data_(detail::types::dispatch_error_tag{}, std::move(exception));
|
||||
}
|
||||
|
||||
@ -51,6 +51,9 @@ namespace cti {
|
||||
/// The most important method is the cti::continuable_base::then() method,
|
||||
/// which allows to attach a callback to the continuable.
|
||||
///
|
||||
/// Use the continuable types defined in `continuable/continuable.hpp`,
|
||||
/// in order to use this class.
|
||||
///
|
||||
/// \tparam Data The internal data which is used to store the current
|
||||
/// continuation and intermediate lazy connection result.
|
||||
///
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user