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

Overview

template<typename T, typename FutureType>
class pw::async2::ValueListProvider< T, FutureType >

A general purpose, multi-consumer provider that manages a list of pending futures.

ValueListProvider allows multiple distinct tasks (potentially running on different dispatchers) to register futures in a list. The provider owner can inspect, conditionally resolve, or bulk-abort pending futures from anywhere in the list.

Template Parameters
TThe type of value provided by the futures.
FutureTypeThe type of future vended, defaulting to ValueFuture<T>.

Public Member Functions

 ValueListProvider (ValueListProvider &&other) noexcept
 
ValueListProvideroperator= (ValueListProvider &&other) noexcept
 
 ValueListProvider (const ValueListProvider &)=delete
 
ValueListProvideroperator= (const ValueListProvider &)=delete
 
template<typename... Args>
FutureType Get (Args &&... args)
 Vends a future and automatically registers it in the pending list.
 
bool empty () const
 Returns true if the list contains no pending futures.
 
size_t size () const
 Returns the number of pending futures.
 
template<typename... Args, typename U = T, std::enable_if_t<!std::is_void_v< U >, int > = 0>
void ResolveFirst (Args &&... args)
 Resolves the first (oldest) pending future in the list.
 
template<typename U = T, std::enable_if_t< std::is_void_v< U >, int > = 0>
void ResolveFirst ()
 Resolves the first (oldest) pending future in the list.
 
template<typename F >
bool ResolveFirstMatching (F &&callback)
 
template<typename F >
size_t ResolveAllMatching (F &&callback)
 
template<typename F >
void ResolveAll (F &&callback)
 Bulk-resolves all pending futures in the list.
 

Member Function Documentation

◆ ResolveAllMatching()

template<typename T , typename FutureType >
template<typename F >
size_t pw::async2::ValueListProvider< T, FutureType >::ResolveAllMatching ( F &&  callback)
inline

Iterates through the list and resolves ALL futures where the callback returns a value (or true for void).

Returns
The number of futures resolved and removed.

◆ ResolveFirstMatching()

template<typename T , typename FutureType >
template<typename F >
bool pw::async2::ValueListProvider< T, FutureType >::ResolveFirstMatching ( F &&  callback)
inline

Iterates through the list and resolves the FIRST future where the callback returns a value (or true for void).

Returns
true if a future was resolved and removed, false otherwise.

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