Template Class MultiFuture
Defined in File exathread.hpp
Class Documentation
-
template<typename T>
class MultiFuture Aggregate container of multiple futures.
Public Functions
-
MultiFuture(std::initializer_list<Future<T>>)
Create a MultiFuture with a collection of futures.
- Throws:
std::logic_error – If any of the futures belongs to a different pool from the others
std::length_error – If the list of futures is empty
-
explicit MultiFuture(std::vector<Future<T>>&&)
Create a MultiFuture with a collection of futures.
- Throws:
std::logic_error – If any of the futures belongs to a different pool from the others
std::length_error – If the list of futures is empty
-
std::size_t size() const noexcept
Get the number of collected futures.
- Returns:
Future count
-
Status checkStatus() const noexcept
Get the overall status of the collection.
The status progresses as follows: starting at Pending (then Scheduled once scheduled to run), once any future starts executing the status is set to Executing, then Complete once all futures have completed.
The status will be set to Failed if any future fails. The Yielding status is never returned.
- Returns:
The overall status
-
template<typename F, typename ...ExArgs, typename R = std::invoke_result_t<F&&, std::vector<T>, ExArgs&&...>>
Future<R> then(F &&func, ExArgs&&... exargs) Schedule a tracked task for execution after these futures.
- Template Parameters:
F – Function type
ExArgs – Arguments to the function
R – Function return type
- Parameters:
func – The function to invoke
exargs – Extra arguments to pass to the function
- Throws:
std::logic_error – If any of the futures fail
std::bad_weak_ptr – If the pool to which the futures belong no longer exists
-
template<typename F, typename ...ExArgs>
void thenDetached(F &&func, ExArgs&&... exargs) Schedule a tracked task for execution after these futures with no result.
- Template Parameters:
F – Function type
ExArgs – Extra arguments to the function
- Parameters:
func – The function to invoke
exargs – Extra arguments to pass to the function
- Throws:
std::logic_error – If any of the futures fail
std::bad_weak_ptr – If the pool to which the futures belong no longer exists
-
template<typename F, typename ...ExArgs, typename R = std::invoke_result_t<F&&, T, ExArgs&&...>>
MultiFuture<R> thenBatch(F &&func, ExArgs&&... exargs) Schedule a tracked batch job based on a container for execution after these futures.
This function does not exist in the
void
specialization of this type- Attention
If some futures fail but others do not and a batch continuation has been scheduled, the successful jobs will run their continuations and the failed ones will not. Keep this in mind.
- Template Parameters:
F – Function type
ExArgs – Extra arguments to the function
R – Function return type
- Parameters:
func – The function to invoke
exargs – Extra arguments to pass to the function
- Throws:
std::logic_error – If any of the futures fail
std::bad_weak_ptr – If the pool to which the futures belong no longer exists
-
template<typename F, typename ...ExArgs>
void thenBatchDetached(F &&func, ExArgs&&... exargs) Schedule a batch job based on a container for execution after these futures with no result.
This function does not exist in the
void
specialization of this type- Attention
If some futures fail but others do not and a batch continuation has been scheduled, the successful jobs will run their continuations and the failed ones will not. Keep this in mind.
- Template Parameters:
F – Function type
ExArgs – Extra arguments to the function
- Parameters:
func – The function to invoke
exargs – Extra arguments to pass to the function
- Throws:
std::logic_error – If any of the futures fail
std::bad_weak_ptr – If the pool to which the futures belong no longer exists
-
std::vector<T> results()
Get the results of the futures, blocking if not complete.
This function does not exist in the
void
specialization of this type- Throws:
std::runtime_error – If any of the futures failed
- Returns:
A list of results corresponding to the order of futures as placed in the constructor
-
MultiFuture(std::initializer_list<Future<T>>)