Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Async.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4
5#include <future>
6#include <vector>
7
9
10 template <invocable<>... I>
11 void RunAll (I... functions)
12 {
13 vector<future<void>> futures;
14
15 // @todo is simple way to iterate without converting to function<>
16 for (auto fi : initializer_list<function<void ()>>{forward<I> (functions)...}) {
17 futures.push_back (async (launch::async, fi));
18 }
19
20 // Wait for all tasks to complete
21 for (auto& future : futures) {
22 future.wait ();
23 }
24 }
25
26}
void RunAll(I... functions)
Run all the argument functions (logically/potentially) in parallel, and wait until they all complete.
Definition Async.inl:11