Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Async.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Execution_Async_h_
5#define _Stroika_Foundation_Execution_Async_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include <concepts>
10
11#include "Stroika/Foundation/Common/Common.h"
12
13/*
14 *
15 * \note Code-Status: <a href="Code-Status.md#Alpha">Alpha</a>
16 *
17 */
18
20
21 /**
22 * \brief Run all the argument functions (logically/potentially) in parallel, and wait until they all complete.
23 *
24 * Could be implemented with std::async, or ThreadPool.
25 *
26 * @todo describe if any of the functions throw... (probably rethrow the first, but NYI) - and then does this interrupt the rest?
27 * Probably SHOULD but not clear always can.
28 *
29 * @todo could enhance this to also return tuple of return results of each function;
30 * no guarantee all run in parallel, but suggestion they are. Typically will auto-allocate threadpool of size
31 * #virtual CPUs (hardware_parallelism).
32 */
33 template <invocable<>... I>
34 void RunAll (I... functions);
35
36}
37
38/*
39 ********************************************************************************
40 ***************************** Implementation Details ***************************
41 ********************************************************************************
42 */
43#include "Async.inl"
44
45#endif /*_Stroika_Foundation_Execution_Async_h_*/
void RunAll(I... functions)
Run all the argument functions (logically/potentially) in parallel, and wait until they all complete.
Definition Async.inl:11