Executors
Executors are the basic building block for execution in C++ and fulfil a similar role for execution such as allocators for the containers in C++. Functions such as async
, the parallel algorithms of the Standard Template Library, the then
continuation of futures, the run methods of task blocks, or the post
, dispatch
, or defer
calls of the Networking TS use them. Also, execution is a fundamental concern of programming there is no standardised way to perform an execution.
Here is the introductory example of the proposal P0761.
void
parallel_for
(
int
facility
,
int
n
,
function
<
void
(
int
)
>
f
)
{
if
(
facility
==
OPENMP
)
{
#pragma omp parallel for
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
f
(
i
);
}
}
else
if
(
facility
==
GPU
)
{
parallel_for_gpu_kernel
<<<
n
>>>
(
f
);
}
else
if
(
facility
==
THREAD_POOL
)
{
global_thread_pool_variable
.
submit
(
n
,
f
);
}
}
This parallel_for
function has a few issues.
- A simple...