Asynchronous Operations

The Asynchronous Operations group gathers classes and functions responsible for asynchronous operations in the Server C++ SDK.

Classes

Name
structdolbyio::comms::thread_safe_solver_traits
Traits that allow for safe implementation of asynchronous classes. They allow public APIs to safely use the objects of these classes.
classdolbyio::comms::detail::solver
An interface that notifies about the completion of asynchronous operations.
classdolbyio::comms::detail::low_level_solver< void, traits >
A specialized template of the low_level_solver class that wraps void results.
classdolbyio::comms::detail::low_level_solver
A shared state of the solver and async_result objects.
classdolbyio::comms::detail::async_result_with_solver
The pair of the solver and the associated async_result.
classdolbyio::comms::detail::async_result
An object that represents the eventual completion or failure of an asynchronous operation and its resulting value.

Types

Name
using dolbyio::comms::detail::solver< T, thread_safe_solver_traits >solver
Partial specialization of the dolbyio::comms::detail::solver template class, ensuring that the operations are thread-safe.
enumresolved_tag { resolved}
The tag type for constructing the resolved async_result objects in place.
enumlow_level_tag { intentional_usage}
The tag type for using low-level APIs of the low_level_solver and async_result.
using detail::low_level_solver_ptr< T, thread_safe_solver_traits >low_level_solver_ptr
The thread-safe version of detail::solver_ptr.
using std::shared_ptr< low_level_solver< T, U > >low_level_solver_ptr
A shared pointer to the low_level_solver object.
using detail::low_level_solver< T, thread_safe_solver_traits >low_level_solver
The thread-safe version of the detail::solver.
enumfailed_tag { failed}
The tag type for constructing the resolved with failure async_result objects in place.
using dolbyio::comms::detail::async_result_with_solver< T, thread_safe_solver_traits >async_result_with_solver
Partial specialization of the dolbyio::comms::detail::solver template class, ensuring that the operations are thread-safe.
using detail::async_result< T, thread_safe_solver_traits >async_result
The thread-safe version of detail::async_result.

Functions

Name
template <typename T >
T
wait(async_result< T > && asyncop)
Waits for the asynchronous operation to complete and returns the T type when the operation finishes. This call is synchronous and blocks the calling thread until the result is available. The method either returns an object of type T or throws an exception if the solver of async_result fails.

Types Documentation

using solver

using dolbyio::comms::solver = typedef dolbyio::comms::detail::solver<T, thread_safe_solver_traits>;

Partial specialization of the dolbyio::comms::detail::solver template class, ensuring that the operations are thread-safe.

enum resolved_tag

EnumeratorDescription
resolved

The tag type for constructing the resolved async_result objects in place.

enum low_level_tag

EnumeratorDescription
intentional_usage

The tag type for using low-level APIs of the low_level_solver and async_result.

Use this tag only if you are aware of the requirements that need to be satisfied in order to let APIs work correctly.

using low_level_solver_ptr

using dolbyio::comms::low_level_solver_ptr = typedef detail::low_level_solver_ptr<T, thread_safe_solver_traits>;

The thread-safe version of detail::solver_ptr.

Template Parameters:

  • T The result type that is wrapped by the underlying solver.

using low_level_solver_ptr

using dolbyio::comms::detail::low_level_solver_ptr = typedef std::shared_ptr<low_level_solver<T, U> >;

A shared pointer to the low_level_solver object.

using low_level_solver

using dolbyio::comms::low_level_solver = typedef detail::low_level_solver<T, thread_safe_solver_traits>;

The thread-safe version of the detail::solver.

Template Parameters:

  • T The result type that is wrapped by the underlying solver.

enum failed_tag

EnumeratorDescription
failed

The tag type for constructing the resolved with failure async_result objects in place.

using async_result_with_solver

using dolbyio::comms::async_result_with_solver = typedef dolbyio::comms::detail::async_result_with_solver<T, thread_safe_solver_traits>;

Partial specialization of the dolbyio::comms::detail::solver template class, ensuring that the operations are thread-safe.

using async_result

using dolbyio::comms::async_result = typedef detail::async_result<T, thread_safe_solver_traits>;

The thread-safe version of detail::async_result.

Template Parameters:

  • T The result type that is wrapped by the underlying solver.

Functions Documentation

function wait

template <typename T >
T wait(
    async_result< T > && asyncop
)

Waits for the asynchronous operation to complete and returns the T type when the operation finishes. This call is synchronous and blocks the calling thread until the result is available. The method either returns an object of type T or throws an exception if the solver of async_result fails.

Parameters:

  • asyncop The async_result object that wraps a solver that contains the T return type.

Exceptions:

Template Parameters:

  • T The type of object that is returned asynchronously.

Return: The object of type T.

try {
  auto value = wait(some_async_operation());
}
catch (std::exception& e) {
  std::cerr << e.what() << std::endl;
}


Did this page help you?