.. _ex_any:

tmc::ex_any
-----------------------------------------------------------------------------------
``ex_any`` is a type-erased wrapper over any TMC executor. You will typically interact with it via
an ``ex_any*`` which can be obtained by calling the ``type_erased()`` member function of any
TMC executor.

This is also the type returned by calling ``tmc::current_executor()``.

Any TMC function that accepts an ``Executor`` template parameter (such as :literal_ref:`resume_on()<aw_resume_on>`)
can accept a real executor type, or an ``ex_any*``.

Usage Example
-----------------------------------------------------------------------------------

.. code-block:: cpp

  #define TMC_IMPL
  #include "tmc/all_headers.hpp"
  #include "tmc/asio/ex_asio.hpp"

  static const bool UseCpuExecutor = true;

  int main() {
    tmc::cpu_executor().init();
    tmc::asio_executor().init();

    // Use this variable to do a runtime switch between different executor types.
    tmc::ex_any* whichExec;
    if (UseCpuExecutor) {
      whichExec = tmc::cpu_executor().type_erased();
    } else {
      whichExec = tmc::asio_executor().type_erased();
    }

    tmc::post_waitable(whichExec, main_task()).wait();
  }

API Reference
-----------------------------------------------------------------------------------
.. doxygenclass:: tmc::ex_any
   :members:
