Improve the documentation of promise and continuable

This commit is contained in:
Denis Blank 2017-10-03 02:42:19 +02:00
parent 52cf1ab929
commit b8b9f31024
3 changed files with 24 additions and 0 deletions

View File

@ -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.

View File

@ -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));
}

View File

@ -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.
///