userver: drivers::SubscribableFutureWrapper< SubscribableFuture > Class Template Reference
Loading...
Searching...
No Matches
drivers::SubscribableFutureWrapper< SubscribableFuture > Class Template Referencefinal

#include <userver/drivers/subscribable_futures.hpp>

Detailed Description

template<typename SubscribableFuture>
class drivers::SubscribableFutureWrapper< SubscribableFuture >

An adaptor for working with certain external futures.

The SubscribableFuture must have a Subscribe(Callback) method that calls the callback when the future is ready. If the future is already ready, then Subscribe must call the callback immediately. If the promise is dropped and will never be fulfilled properly, then the SubscribableFuture should call the callback anyway.

See also
drivers::WaitForSubscribableFuture
drivers::TryWaitForSubscribableFuture

Definition at line 41 of file subscribable_futures.hpp.

Public Member Functions

 SubscribableFutureWrapper (SubscribableFuture &&future)
 
SubscribableFuture & GetFuture ()
 
void Wait ()
 Wait for the future. The result can be retrieved from the original future using GetFuture once ready.
 
engine::FutureStatus TryWaitUntil (engine::Deadline deadline)
 Wait for the future. The result can be retrieved from the original future using GetFuture once ready.
 

Constructor & Destructor Documentation

◆ SubscribableFutureWrapper()

template<typename SubscribableFuture >
drivers::SubscribableFutureWrapper< SubscribableFuture >::SubscribableFutureWrapper ( SubscribableFuture && future)
inlineexplicit

Definition at line 43 of file subscribable_futures.hpp.

Member Function Documentation

◆ GetFuture()

template<typename SubscribableFuture >
SubscribableFuture & drivers::SubscribableFutureWrapper< SubscribableFuture >::GetFuture ( )
inline
Returns
the original future

Definition at line 50 of file subscribable_futures.hpp.

◆ TryWaitUntil()

template<typename SubscribableFuture >
engine::FutureStatus drivers::SubscribableFutureWrapper< SubscribableFuture >::TryWaitUntil ( engine::Deadline deadline)
inline

Wait for the future. The result can be retrieved from the original future using GetFuture once ready.

Returns
an error code if deadline is exceeded or task is cancelled

Definition at line 64 of file subscribable_futures.hpp.

◆ Wait()

template<typename SubscribableFuture >
void drivers::SubscribableFutureWrapper< SubscribableFuture >::Wait ( )
inline

Wait for the future. The result can be retrieved from the original future using GetFuture once ready.

Exceptions
engine::WaitInterruptedExceptionon task cancellation

Definition at line 55 of file subscribable_futures.hpp.


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