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 | |
| SingleFutureProvider & | operator= (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 |
|
inline |
Claims the provider's future, leaving it unset. Crashes if there is no future set.