AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
AFutureSet< T > Class Template Reference

Manages multiple futures. More...

Detailed Description

template<typename T = void>
class AFutureSet< T >

Manages multiple futures.

Template Parameters
Tfuture's return type

AFutureSet involves functions to efficiently manage multiple AFutures.

Guarantees that held futures will never be executed or be during execution after AAsyncHolder is destroyed.

Public Member Functions

void waitForAll ()
 Wait for the result of every AFuture. More...
 
void checkForExceptions () const
 Find AFutures that encountered an exception. If such AFuture is found, AInvocationTargetException is thrown.
 
template<aui::invocable OnComplete>
void onAllComplete (OnComplete &&onComplete)
 Specifies a callback which will be called when all futures in future set would have the result. More...
 
- Public Member Functions inherited from AVector< AFuture< void > >
 AVector (aui::range< Iterator > range)
 
 AVector (std::vector< AFuture< void >, Allocator > &&rhs) noexcept
 
iterator insertAll (const OtherContainer &c) noexcept
 
iterator insertAll (OtherContainer &&c) noexcept
 
iterator insertAll (iterator at, const OtherContainer &c) noexcept
 
iterator insertAll (iterator at, OtherContainer &&c) noexcept
 
void removeAll (const AFuture< void > &item) noexcept
 
void removeAll (const T &item, Projection projection) noexcept
 
AOptional< std::size_t > removeFirst (const AFuture< void > &item) noexcept
 
bool isSubsetOf (const OtherContainer &c) const noexcept
 
bool contains (const AFuture< void > &value) const noexcept
 
std::size_t sizeInBytes () const noexcept
 
AFuture< void > & at (std::size_t index)
 
const AFuture< void > & at (std::size_t index) const
 
selfoperator<< (const AFuture< void > &rhs) noexcept
 
selfoperator<< (AFuture< void > &&rhs) noexcept
 
selfoperator<< (const OtherContainer &c) noexcept
 
selfoperator<< (OtherContainer &&c) noexcept
 
AFuture< void > & first () noexcept
 
const AFuture< void > & first () const noexcept
 
AFuture< void > & last () noexcept
 
const AFuture< void > & last () const noexcept
 
size_t indexOf (const AFuture< void > &value) const noexcept
 
AVector< AFuture< void > > & sort () noexcept
 
AVector< AFuture< void > > & sort (Comparator &&comparator) noexcept
 
AFuture< void > * findIf (Predicate &&predicate) noexcept
 Finds element by predicate. More...
 
void removeAt (size_t index) noexcept
 
void removeIf (Predicate &&predicate) noexcept
 
void removeIfFirst (Predicate &&predicate) noexcept
 
ASet< AFuture< void > > toSet () const noexcept
 
auto map (UnaryOperation &&transformer) -> AVector< decltype(transformer(std::declval< AFuture< void > & >()))>
 
auto map (UnaryOperation &&transformer) const -> AVector< decltype(transformer(std::declval< AFuture< void > >()))>
 
auto toMap (UnaryOperation &&transformer) const -> AMap< decltype(transformer(std::declval< AFuture< void > >()).first), decltype(transformer(std::declval< AFuture< void > >()).second)>
 
auto toMap (UnaryOperation &&transformer) -> AMap< decltype(transformer(std::declval< AFuture< void > >()).first), decltype(transformer(std::declval< AFuture< void > >()).second)>
 
self filter (Predicate &&predicate)
 

Additional Inherited Members

- Public Types inherited from AVector< AFuture< void > >
using iterator = typename super::iterator
 
- Static Public Member Functions inherited from AVector< AFuture< void > >
static AVector< AFuture< void >, Allocator > generate (size_t size, Callable &&callable) noexcept
 
static auto fromRange (aui::range< Iterator > range, UnaryOperation &&transformer) -> AVector< decltype(transformer(range.first()))>
 Constructs a new vector of transformed items of the range. More...
 
- Protected Types inherited from AVector< AFuture< void > >
using super = std::vector< AFuture< void >, Allocator >
 
using self = AVector< AFuture< void >, Allocator >
 

Member Function Documentation

◆ onAllComplete()

template<typename T = void>
template<aui::invocable OnComplete>
void AFutureSet< T >::onAllComplete ( OnComplete &&  onComplete)
inline

Specifies a callback which will be called when all futures in future set would have the result.

Even if all tasks are already completed, it's guaranteed that your callback will be called.

The thread on which your callback will be called is undefined.

Note
AFutureSet is not required to be alive when AFutures would potentially call onSuccess callback since a temporary object is created to keep track of the task completeness.

◆ waitForAll()

template<typename T = void>
void AFutureSet< T >::waitForAll ( )
inline

Wait for the result of every AFuture.

Deprecated:
use onAllComplete instead.

#include <AUI/Thread/AThreadPool.h>


The documentation for this class was generated from the following file:
Inheritance diagram for AFutureSet< T >:
Collaboration diagram for AFutureSet< T >: