detail::solver

Module: Asynchronous Operations

An interface that notifies about the completion of asynchronous operations.

Template Parameters:

  • T The type of the result produced by the asynchronous operation.
  • traits The traits type. For more information, refer to the documentation of the async_result class.

When the asynchronous operation is finished, the fail() or resolve() method of the solver is invoked to bring the associated async_result to the resolved state or invoke the callbacks if the async_result has already been finalized. The solver class ensures that the resolution can happen only once, and that the destruction of the pending solver results in resolving the operation with failure.

The solver class implements move semantics and should be always passed by move to the entity which eventually resolves it. The moved-from state of the solver is invalid and the only allowed operations on the invalid solver are the destruction, move-assignment, and validity check.

#include <async_result_detail.h>

Public Functions

Name
~solver()
The destructor.
solver() =default
The default constructor.
solver(low_level_solver_ptr< T, traits > slv)
The constructor.
solver(solver< T, traits > && ) =default
solver(const solver< T, traits > & ) =delete
template <typename TT =T,typename X =std::enable_if_t<std::is_same_v<void, TT>, TT>>
void
resolve()
Notifies about the successful async operation.
template <typename TT =T,typename X =std::enable_if_t<!std::is_same_v<void, TT>, TT>>
void
resolve(TT && val)
Notifies about the successful async operation.
solver &operator=(solver< T, traits > && other)
solver &operator=(const solver< T, traits > & ) =delete
operator bool() const
Checks validity of the solver object.
voidfail(std::exception_ptr && e)
Notifies about the failed async operation.
template <typename T,
typename traits>
class dolbyio::comms::detail::solver;

Public Functions Documentation

function ~solver

inline ~solver()

The destructor.

If the solver is valid and has not been resolved or failed, the destructor fails the solver with the dolbyio::comms::async_operation_canceled exception.

function solver

solver() =default

The default constructor.

Constructs an invalid solver. Invoking resolve() or fail() on this solver instance results in assertion failures.

function solver

inline solver(
    low_level_solver_ptr< T, traits > slv
)

The constructor.

Constructs a solver. We do not recommend to invoke this constructor directly. The recommended way of creating solvers is to use the async_result::make() method which creates the solver and the associated async_result in a safe way.

function solver

solver(
    solver< T, traits > && 
) =default

function solver

solver(
    const solver< T, traits > & 
) =delete

function resolve

template <typename TT  =T,
typename X  =std::enable_if_t<std::is_same_v<void, TT>, TT>>
inline void resolve()

Notifies about the successful async operation.

This method causes the associated async_result to change the state to resolved with success or the method invokes the value callback directly if the associated async_result object is already in the finalized state. This method consumes the solver object and changes its state to invalid.

function resolve

template <typename TT  =T,
typename X  =std::enable_if_t<!std::is_same_v<void, TT>, TT>>
inline void resolve(
    TT && val
)

Notifies about the successful async operation.

Parameters:

  • val The value produced by the asynchronous operation.

This method causes the associated async_result to change the state to resolved with success or the method invokes the value callback directly if the associated async_result object is already in the finalized state. This method consumes the solver object and changes its state to invalid.

function operator=

inline solver & operator=(
    solver< T, traits > && other
)

function operator=

solver & operator=(
    const solver< T, traits > & 
) =delete

function operator bool

inline explicit operator bool() const

Checks validity of the solver object.

Return: True if the solver is valid, false otherwise.

function fail

inline void fail(
    std::exception_ptr && e
)

Notifies about the failed async operation.

Parameters:

  • e the exception.

This method causes the associated async_result to change the state to resolved with failure or the method invokes the callbacks in the failure paths directly if the associated async_result object is already in the finalized state. This method consumes the solver object and changes its state to invalid.



Did this page help you?