tmc::spawn_func()

tmc::spawn_func()#

spawn_func() produces a wrapper that converts any functor (invocable) into an awaitable type. This wrapper exposes several customization functions that allow you to control where it runs and how the awaiting task is resumed.

It supports these Awaitable Customizations: run_on(), resume_on(), with_priority(), co_await, fork(), detach()

API Reference#

template<typename Func, typename ...Arguments>
auto tmc::spawn_func(Func &&func, Arguments&&... args) -> aw_spawn_func<decltype(func(args...))>#

Wraps a function into a new task by std::binding the Func to its Args, and wrapping them into a type that allows you to customize the task behavior before submitting it for execution.

Before the task is submitted for execution, you may call any or all of run_on(), resume_on(), with_priority(). The task must then be submitted for execution by calling exactly one of: co_await, fork() or detach().