Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
future_utils.H File Reference

Utility functions for working with std::future collections. More...

#include <future>
#include <tpl_dynList.H>
Include dependency graph for future_utils.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 

Functions

template<typename T >
DynList< TAleph::get_futures (DynList< std::future< T > > &future_list)
 Collect results from a list of futures.
 
template<typename T >
DynList< TAleph::get_futures (DynList< std::future< T > > &&future_list)
 Collect results from a list of futures (rvalue overload).
 
void Aleph::get_futures (DynList< std::future< void > > &future_list)
 Wait for all void futures to complete.
 
void Aleph::get_futures (DynList< std::future< void > > &&future_list)
 Wait for all void futures to complete (rvalue overload).
 
template<typename T >
bool Aleph::all_ready (DynList< std::future< T > > &future_list)
 Check if all futures in a list are ready.
 
template<typename T >
size_t Aleph::count_ready (DynList< std::future< T > > &future_list)
 Count how many futures are ready.
 

Detailed Description

Utility functions for working with std::future collections.

This header provides convenient functions for collecting results from a list of std::future objects. It simplifies the common pattern of waiting for multiple asynchronous operations to complete and gathering their results.

Example Usage

#include <future_utils.H>
#include <async>
// Launch multiple async tasks
DynList<std::future<int>> futures;
for (int i = 0; i < 10; ++i)
futures.append(std::async(std::launch::async, [i] { return i * i; }));
// Collect all results (blocks until all complete)
DynList<int> results = get_futures(futures);
// results now contains: 0, 1, 4, 9, 16, 25, 36, 49, 64, 81
Utility functions for working with std::future collections.
Author
Leandro Rabindranath León

Definition in file future_utils.H.