Executors

Get a detailed introduction to the executors, supposedly a part of C++23.

Executors have quite a history in C++. The discussion began in early 2010. For the details, Detlef Vollmanns gives in his presentation Finally Executors for C++ an excellent overview.

My introduction to executors is mainly based on the proposals for the design of executors P0761, and for their formal description P0443. I also refer to the relatively new Modest Executor Proposal P1055.

What are executors?

Executors are the basic building blocks for execution in C++ and fulfill a similar role for execution, such as allocators for the containers in C++. Many proposals for executors are published, and many design decisions are still open. They should be part of C++23, but can probably be used much earlier to extend the C++ standard.

An executor consists of rules about where, when, and how to run a callable.

  • Where: The callable may run on an internal or external processor, and that the result is read back from the internal or external processor.
  • When: The callable may run immediately or just be scheduled.
  • How: The callable may run on a CPU or GPU or even be executed in a vectorized way.

The concurrency and parallelism features of C++ heavily depend on executors as building blocks for execution. This dependency holds for existing concurrency features, such as the parallel algorithms of the Standard Template Library, but also for new concurrency features, such as ...