PdCom  5.3
Process data communication client
Classes | Public Types | Public Member Functions | List of all members
PdCom::Future< Exception, Result > Class Template Reference

Callback management handle. More...

#include <Future.h>

Classes

struct  Hash
 Hash support, e.g. for std::unordered_set. More...
 
struct  Less
 Less compare support, e.g. for std::set. More...
 

Public Types

using ResolveFn = std::function< void(Result...)>
 
using RejectFn = std::function< void(Exception)>
 

Public Member Functions

 Future ()=default
 Default Constructor.
 
 Future (std::shared_ptr< impl::Promise< Exception, Result... >> impl) noexcept
 
 Future (Future &&)=default
 
 Future (const Future &)=delete
 
Futureoperator= (Future &&)=default
 
Futureoperator= (const Future &)=delete
 
const Futurethen (ResolveFn resolve) const &
 Set continuation callback. More...
 
Future then (ResolveFn resolve) &&
 Set continuation callback. More...
 
const Futurehandle_exception (RejectFn reject) const &
 Set error handling callback. More...
 
Future handle_exception (RejectFn reject) &&
 Set error handling callback. More...
 
bool empty () const noexcept
 
bool operator== (const Future &other) const noexcept
 Equal comparsion.
 

Detailed Description

template<class Exception, class... Result>
class PdCom::Future< Exception, Result >

Callback management handle.

This class can save up to two callbacks for an asynchronous operation. When the result of the asynchronous operation arrives, the callback set by then() is called. On error, handle_exception() is invoked.

Please note that this Future does not support fire-and-forget. The Future should be kept until one of the callback was called. If you're not interested in the result anymore, you can delete the future. In this case, no callbacks are run.

Member Function Documentation

◆ empty()

template<class Exception , class... Result>
bool PdCom::Future< Exception, Result >::empty ( ) const
inlinenoexcept
Returns
true if the Future was default-constructed.

◆ handle_exception() [1/2]

template<class Exception , class... Result>
const Future& PdCom::Future< Exception, Result >::handle_exception ( RejectFn  reject) const &

Set error handling callback.

Parameters
rejectThe callback to be invoked on error.
Returns
const Reference to this.

◆ handle_exception() [2/2]

template<class Exception , class... Result>
Future PdCom::Future< Exception, Result >::handle_exception ( RejectFn  reject) &&

Set error handling callback.

Parameters
rejectThe callback to be invoked on error.
Returns
a new Future.

◆ then() [1/2]

template<class Exception , class... Result>
const Future& PdCom::Future< Exception, Result >::then ( ResolveFn  resolve) const &

Set continuation callback.

Parameters
resolveThe callback to be invoked with the result.
Returns
const Reference to this.

◆ then() [2/2]

template<class Exception , class... Result>
Future PdCom::Future< Exception, Result >::then ( ResolveFn  resolve) &&

Set continuation callback.

Parameters
resolveThe callback to be invoked with the result.
Returns
a new Future.

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