Executors
-----------------------------------------------------------------------------------

.. toctree::
   :hidden:
   :maxdepth: 1

   ex_cpu
   ex_braid
   ex_any

Executors accept work into a queue and run it by calling ``operator()()`` on the provided work item.
The following executors are provided by the core library of TooManyCooks:

.. list-table::
   :widths: 25 75
   :header-rows: 0

   * - :ref:`tmc::ex_cpu <ex_cpu>`
     - general-purpose multi-threaded executor
   * - :ref:`tmc::ex_braid <ex_braid>`
     - serializing executor
   * - :ref:`tmc::ex_any <ex_any>`
     - type-erased wrapper that can represent any TMC executor

Other libraries in the TMC ecosystem provide the following executors:

.. list-table::
   :widths: 25 75
   :header-rows: 0

   * - `tmc::ex_asio <https://github.com/tzcnt/tmc-asio>`_
     - I/O executor built on the Asio library

Each executor instance manages a completely independent set of resources / threads, and you can create multiple of the same
kind of executor if you wish. For example, it may be useful to create a secondary single-threaded :literal_ref:`tmc::ex_cpu<ex_cpu>`
to manage communication with certain systems that require all calls to come from the same thread (e.g. SDL/OpenGL). This can be created
in addition to the primary multi-threaded instance of :literal_ref:`tmc::ex_cpu<ex_cpu>`.

Work can be submitted for execution to any executor using the :literal_ref:`tmc::post()<post>` / :literal_ref:`tmc::post_bulk()<post_bulk>` functions.

From within a task that is already running on an executor, :literal_ref:`tmc::spawn()<spawn>` / :literal_ref:`tmc::spawn_many()<spawn_many>` can be used to submit work to the same executor.

For more information on how to integrate your own executor with TMC, see :ref:`Integrating External Executors<external_executors>`.
