olp-cpp-sdk  1.18.1
Public Types | Public Member Functions | List of all members
olp::client::CancellableFuture< T > Class Template Reference

A wrapper template that you can use to cancel a request or wait for it to finalize. More...

#include <ApiResponse.h>

Public Types

using PromisePtr = std::shared_ptr< std::promise< T > >
 The sharable promise type.
 

Public Member Functions

 CancellableFuture (const CancellationToken &cancel_token, PromisePtr promise)
 Creates the CancellableFuture instance with CancellationToken and std::promise. More...
 
const CancellationTokenGetCancellationToken () const
 Gets the CancellationToken reference used to cancel the ongoing operation. More...
 
std::future< T > GetFuture () const
 Gets the future associated with the std::promise that you specified during initialization. More...
 

Detailed Description

template<typename T>
class olp::client::CancellableFuture< T >

A wrapper template that you can use to cancel a request or wait for it to finalize.

Template Parameters
TThe result type.

Constructor & Destructor Documentation

◆ CancellableFuture()

template<typename T >
olp::client::CancellableFuture< T >::CancellableFuture ( const CancellationToken cancel_token,
PromisePtr  promise 
)
inline

Creates the CancellableFuture instance with CancellationToken and std::promise.

Parameters
cancel_tokenThe CancellationToken instance.
promiseThe PromisePtr instance.

Member Function Documentation

◆ GetCancellationToken()

template<typename T >
const CancellationToken& olp::client::CancellableFuture< T >::GetCancellationToken ( ) const
inline

Gets the CancellationToken reference used to cancel the ongoing operation.

Returns
The constant reference to the CancellationToken instance.

◆ GetFuture()

template<typename T >
std::future<T> olp::client::CancellableFuture< T >::GetFuture ( ) const
inline

Gets the future associated with the std::promise that you specified during initialization.

Returns
The future with the result of the asynchronous request.

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