template<typename Data, typename Hint>
cti::promise_base class

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_types.hpp, in order to use this class.

If we want to resolve the promise_base trough the call operator, and we want to resolve it through an exception, we must call it with a exception_arg_t as first and the exception as second argument. Additionally the promise is resolveable only through its call operator when invoked as an r-value.

Constructors, destructors, conversion operators

promise_base() defaulted explicit
Constructor for constructing an empty promise.
promise_base(Data data) explicit
Constructor accepting the data object.
template<typename OData, std::enable_if_t<std::is_convertible<detail::traits::unrefcv_t<OData>, Data>::value>* = nullptr>
promise_base(OData&& data)
Constructor accepting any object convertible to the data object.
operator bool() const explicit noexcept
Returns true if the continuation is valid (non empty).

Public functions

template<typename OData, std::enable_if_t<std::is_convertible<detail::traits::unrefcv_t<OData>, Data>::value>* = nullptr>
auto operator=(OData&& data) -> promise_base&
Assignment operator accepting any object convertible to the data object.
void operator()(Args... args) &&noexcept
Resolves the continuation with the given values.
void operator()(exception_arg_t tag, exception_t exception) &&noexcept
Resolves the continuation with the given exception.
void set_value(Args... args) noexcept
Resolves the continuation with the given values.
void set_exception(exception_t exception) noexcept
Resolves the continuation with the given exception.
void set_canceled() noexcept
Resolves the continuation with the cancellation token which is represented by a default constructed exception_t.

Function documentation

template<typename Data, typename Hint>
cti::promise_base<Data, Hint>::operator bool() const explicit noexcept

Returns true if the continuation is valid (non empty).

Exceptions
This method never throws an exception.

template<typename Data, typename Hint>
void cti::promise_base<Data, Hint>::operator()(Args... args) &&noexcept

Resolves the continuation with the given values.

Exceptions
This method never throws an exception.

template<typename Data, typename Hint>
void cti::promise_base<Data, Hint>::operator()(exception_arg_t tag, exception_t exception) &&noexcept

Resolves the continuation with the given exception.

Exceptions
This method never throws an exception.

template<typename Data, typename Hint>
void cti::promise_base<Data, Hint>::set_value(Args... args) noexcept

Resolves the continuation with the given values.

Exceptions
This method never throws an exception.

template<typename Data, typename Hint>
void cti::promise_base<Data, Hint>::set_exception(exception_t exception) noexcept

Resolves the continuation with the given exception.

Exceptions
This method never throws an exception.

template<typename Data, typename Hint>
void cti::promise_base<Data, Hint>::set_canceled() noexcept

Resolves the continuation with the cancellation token which is represented by a default constructed exception_t.

Exceptions
This method never throws an exception.