C/C++ API Reference
Loading...
Searching...
No Matches
pw::async2::ValueProvider< T > Class Template Reference

Overview

template<typename T>
class pw::async2::ValueProvider< T >

A one-to-one provider for a single value.

An ValueProvider can only vend one ValueFuture at a time.

This provider is multi-shot: after Resolve is called, a new future can be retrieved with Get to wait for the next Resolve event.

Public Member Functions

ValueFuture< T > Get ()
 
std::optional< ValueFuture< T > > TryGet ()
 
bool has_future ()
 Returns true if the provider stores a pending future.
 
template<typename... Args, typename U = T, std::enable_if_t<!std::is_void_v< U >, int > = 0>
void Resolve (Args &&... args)
 Resolves the pending ValueFuture by constructing its value in-place.
 
template<typename U = T, std::enable_if_t< std::is_void_v< U >, int > = 0>
void Resolve ()
 Resolves the pending ValueFuture.
 

Member Function Documentation

◆ Get()

template<typename T >
ValueFuture< T > pw::async2::ValueProvider< T >::Get ( )
inline

Returns a ValueFuture that will be completed when Resolve is called.

If a future has already been vended and is still pending, this crashes.

◆ TryGet()

template<typename T >
std::optional< ValueFuture< T > > pw::async2::ValueProvider< T >::TryGet ( )
inline

Returns a ValueFuture that will be completed when Resolve is called.

If a future has already been vended and is still pending, this will return std::nullopt.


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