morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::async::Completion< T >::Promise Class Reference

Producer-side handle paired with a Completion<T> by makeSettleable(). More...

#include <completion.hpp>

Public Member Functions

 Promise (Promise &&) noexcept=default
 Move constructor — transfers ownership of the shared state.
Promise & operator= (Promise &&) noexcept=default
 Move assignment — transfers ownership of the shared state.
 Promise (const Promise &)=delete
Promise & operator= (const Promise &)=delete
void resolve (T val)
 Resolves the paired Completion<T> with val.
void reject (std::exception_ptr exc)
 Rejects the paired Completion<T> with exc.

Detailed Description

template<typename T>
class morph::async::Completion< T >::Promise

Producer-side handle paired with a Completion<T> by makeSettleable().

Promise<T> is the public settling counterpart to Completion<T>: it exposes exactly resolve()/reject() against the same shared state a paired Completion<T> observes via then()/onError(), without ever naming morph::async::detail::CompletionState<T>. Intended for test code that needs to construct a Completion<T> it can settle on demand — e.g. standing in for a Bridge/IBackend round trip — instead of reaching into detail::CompletionState<T> directly (see docs/spec/core/completion.md, "Settleable promise seam").

Move-only, mirroring Completion<T>: exactly one producer settles a given operation.

Definition at line 679 of file completion.hpp.

Member Function Documentation

◆ operator=()

template<typename T>
Promise & morph::async::Completion< T >::Promise::operator= ( Promise && )
defaultnoexcept

Move assignment — transfers ownership of the shared state.

Returns
*this.

◆ resolve()

template<typename T>
void morph::async::Completion< T >::Promise::resolve ( T val)
inline

Resolves the paired Completion<T> with val.

No-op if the state is already settled (first result wins — see detail::CompletionState<T>::setValue), or if this Promise was moved from (mirrors Completion<T>::then()'s null-state no-op). Safe to call from any thread; the delivery is posted to the completion's executor.

Parameters
valSuccess value delivered to every attached then() handler.

Definition at line 698 of file completion.hpp.

◆ reject()

template<typename T>
void morph::async::Completion< T >::Promise::reject ( std::exception_ptr exc)
inline

Rejects the paired Completion<T> with exc.

No-op if the state is already settled (first result wins — see detail::CompletionState<T>::setException), or if this Promise was moved from (mirrors Completion<T>::onError()'s null-state no-op). Safe to call from any thread; the delivery is posted to the completion's executor.

Parameters
excError delivered to every attached onError() handler, or logged as an orphan if none is ever attached.

Definition at line 713 of file completion.hpp.


The documentation for this class was generated from the following file: