detail::low_level_solver

Module: Asynchronous Operations

A shared state of the solver and async_result objects.

Template Parameters:

  • T The type of the result produced by the low_level_solver.
  • traits The traits type.

The class that stores a low-level building block for code that executes asynchronously. The class allows the caller of the asynchronous function to set the callbacks for notification informing that the function has finished. The class also allows executing code asynchronously to notify that it is finished.

The low_level_solver is templated over two types: the type of the produced value and the traits type. Refer to the documentation of the async_result class for the description of the traits type.

The low_level_solver provides a low-level API. The user of this class must adhere to the following rules:

#include <async_result_detail.h>

Inherits from std::enable_shared_from_this< low_level_solver< T, traits > >

Public Functions

Name
~low_level_solver()
The destructor.
boolset_propagate_error_callback(err_cb_type && cb)
Sets an error callback.
boolset_error_callback(err_cb_type && cb)
Sets the local error callback.
voidset_callbacks_from(low_level_solver_ptr< T, traits > other)
Chains the current solver with another solver.
boolset_callback(result_cb_type && cb)
Sets a result callback.
voidresolve(T && res)
Resolves the solver.
low_level_solver(async_result_tags::low_level_tag )
The constructor.
voidfail(std::exception_ptr && error)
Fails the solver.
template <typename T ,
typename traits >
class dolbyio::comms::detail::low_level_solver;

Public Functions Documentation

function ~low_level_solver

inline ~low_level_solver()

The destructor.

function set_propagate_error_callback

inline bool set_propagate_error_callback(
    err_cb_type && cb
)

Sets an error callback.

Parameters:

  • cb The function object to be called in the case of an error.

Return: True if the function object has been invoked immediately, false otherwise.

If the fail() method has already been called, the error callback is executed immediately. Otherwise, the callback is stored to be executed when the fail() method is called.

function set_error_callback

inline bool set_error_callback(
    err_cb_type && cb
)

Sets the local error callback.

Parameters:

  • cb The function object to be called in the case of an error.

Return: True if the function object has been invoked immediately, false otherwise.

If the fail() method has already been called, the error callback is executed immediately. Otherwise, the callback is stored to be executed when the fail() method is called.

The local error callback differs from the error callback that is set by the set_propagate_error_callback(), where the chaining solvers reset the propagated error callbacks and, in case of errors, only the callback of the last solver is invoked. The local error callbacks are invoked for each solver in the chain.

The set_error_callback() function must not be invoked after set_propagate_error_callback() or set_callbacks_from().

function set_callbacks_from

inline void set_callbacks_from(
    low_level_solver_ptr< T, traits > other
)

Chains the current solver with another solver.

Parameters:

  • other The shared pointer to the next solver.

Use this method only if the current low_level_solver does not have any assigned callbacks, except for the local error callback. When the current low_level_solver is resolved, the resolve() or fail() method of the chained solver is called. If the current low_level_solver is already resolved, the result is propagated immediately to the chained solver.

function set_callback

inline bool set_callback(
    result_cb_type && cb
)

Sets a result callback.

Parameters:

  • cb The function object to call when the result is resolved.

Return: True if the function object has been invoked immediately, false otherwise.

If the resolve() method has already been called, the callback is executed immediately. Otherwise, the callback is stored to be invoked if the resolve() method is invoked on the solver.

function resolve

inline void resolve(
    T && res
)

Resolves the solver.

Parameters:

  • res The value to be moved to the callback function.

If there is a callback stored in the solver, the callback is executed immediately with the result. Otherwise, the result is stored for later consumption when the callback is set.

function low_level_solver

inline low_level_solver(
    async_result_tags::low_level_tag 
)

The constructor.

function fail

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

Fails the solver.

Parameters:

  • error The exception pointer that contains the exception.

If the error callback is set for the solver, the solver is invoked. If the current solver is chained with another solver, the fail() method of the chained solver is invoked. If the current solver is not chained with the next solver, the error is stored to be propagated later.



Did this page help you?