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 resume_on())
can accept a real executor type, or an ex_any*.
Usage Example#
#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#
-
class ex_any#
A type-erased executor that may represent any kind of TMC executor.
Public Functions
-
inline void post(work_item &&Item, size_t Priority = 0, size_t ThreadHint = NO_HINT) noexcept#
Submits a single work item to the delegated executor.
-
inline void post_bulk(work_item *Items, size_t Count, size_t Priority = 0, size_t ThreadHint = NO_HINT) noexcept#
Submits
Countwork items from the array pointed to byItemsto the delegated executor.
-
inline ex_any()#
A default constructor is offered so that other executors can initialize this with their own function pointers.
-
inline void post(work_item &&Item, size_t Priority = 0, size_t ThreadHint = NO_HINT) noexcept#