C/C++ API Reference
Loading...
Searching...
No Matches
pw::async2::experimental::SingleFutureProvider< FutureType > Class Template Reference

Overview

template<typename FutureType>
class pw::async2::experimental::SingleFutureProvider< FutureType >

Manages a single future for an asynchronous operation.

An asynchronous operation which can only have a single caller can use a SingleFutureProvider to manage its reference to the future. This can be used with any listable future type, and automatically handles updates during moves.

All operations on the provider are thread-safe.

If the future belonging to the provider is destroyed, it safely removes itself. The provider is not notified of this event.

Public Member Functions

 SingleFutureProvider (const SingleFutureProvider &)=delete
 
SingleFutureProvideroperator= (const SingleFutureProvider &)=delete
 
void Set (FutureType &future)
 Sets the provider's future. Crashes if a future is already set.
 
bool TrySet (FutureType &future)
 Attempts to set the provider's future, returning true if successful.
 
FutureType & Take ()
 
bool has_future ()
 Returns true if the provider has a future.
 

Friends

template<typename , typename >
class ListableFutureWithWaker
 

Member Function Documentation

◆ Take()

template<typename FutureType >
FutureType & pw::async2::experimental::SingleFutureProvider< FutureType >::Take ( )
inline

Claims the provider's future, leaving it unset. Crashes if there is no future set.


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