PdCom
5.3
Process data communication client
|
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 | |
Future & | operator= (Future &&)=default |
Future & | operator= (const Future &)=delete |
const Future & | then (ResolveFn resolve) const & |
Set continuation callback. More... | |
Future | then (ResolveFn resolve) && |
Set continuation callback. More... | |
const Future & | handle_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. | |
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.
|
inlinenoexcept |
const Future& PdCom::Future< Exception, Result >::handle_exception | ( | RejectFn | reject | ) | const & |
Set error handling callback.
reject | The callback to be invoked on error. |
this
. Future PdCom::Future< Exception, Result >::handle_exception | ( | RejectFn | reject | ) | && |
Set error handling callback.
reject | The callback to be invoked on error. |
const Future& PdCom::Future< Exception, Result >::then | ( | ResolveFn | resolve | ) | const & |
Set continuation callback.
resolve | The callback to be invoked with the result. |
this
. Future PdCom::Future< Exception, Result >::then | ( | ResolveFn | resolve | ) | && |
Set continuation callback.
resolve | The callback to be invoked with the result. |