Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
Loading...
Searching...
No Matches
when_helpers.h File Reference

Helper functions for combining multiple futures. More...

#include <atomic>
#include <future>
#include <memory>
#include <thread>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>
Include dependency graph for when_helpers.h:

Go to the source code of this file.

Classes

struct  kcenon::thread::detail::future_value_type< Future >
 Helper to get the value type from a future. More...
 

Namespaces

namespace  kcenon
 
namespace  kcenon::thread
 Core threading foundation of the thread system library.
 
namespace  kcenon::thread::detail
 

Typedefs

template<typename Future >
using kcenon::thread::detail::future_value_type_t = typename future_value_type<Future>::type
 

Functions

template<std::size_t... Is, typename Tuple , typename ResultTuple >
void kcenon::thread::detail::get_all_impl (std::index_sequence< Is... >, Tuple &futures, ResultTuple &results)
 Index sequence helper for when_all implementation.
 
template<typename... Futures>
auto kcenon::thread::when_all (Futures &&... futures) -> std::future< std::tuple< detail::future_value_type_t< std::decay_t< Futures > >... > >
 Wait for all futures to complete and return their results as a tuple.
 
auto kcenon::thread::when_all_empty () -> std::future< std::tuple<> >
 Overload of when_all for no arguments.
 
template<typename T >
auto kcenon::thread::when_any (std::vector< std::future< T > > &&futures) -> std::future< T >
 Wait for any future to complete and return its result.
 
auto kcenon::thread::when_any (std::vector< std::future< void > > &&futures) -> std::future< void >
 Specialization of when_any for void futures.
 
template<typename T >
auto kcenon::thread::when_any_with_index (std::vector< std::future< T > > &&futures) -> std::future< std::pair< std::size_t, T > >
 Wait for any future to complete with index.
 

Detailed Description

Helper functions for combining multiple futures.

This file provides when_all and when_any utilities for waiting on multiple futures efficiently.

Definition in file when_helpers.h.