tmc::spawn_clang()#

tmc::spawn_clang() is a HALO-optimized version of spawn() that uses the [[clang::coro_await_elidable_argument]] attribute when compiled with Clang 20+.

Like spawn(), it does not affect the task unless you specify one of the optional parameters. Its only purpose is to allow you to run work on a different executor or priority without incurring an allocation.

For HALO to work, spawn_clang() must be awaited directly as a prvalue in a co_await expression. Storing the result in a variable before awaiting prevents HALO from being applied.

// HALO: spawn_clang() is directly awaited
auto result = co_await tmc::spawn_clang(some_task(), some_executor());

// Non-HALO: spawn_clang() stored in variable
auto spawned = tmc::spawn_clang(some_task(), some_executor());
auto result = co_await std::move(spawned);

Main Documentation#

For the non-HALO version, see tmc::spawn().

API Reference#

template<typename Awaitable, typename Exec = tmc::ex_any*>
aw_spawn<tmc::detail::forward_awaitable<Awaitable>> tmc::spawn_clang(Awaitable &&Aw, Exec &&Executor = tmc::current_executor(), size_t Priority = tmc::current_priority())#

Similar to tmc::spawn(Aw) but allows the child task’s allocation to be elided by combining it into the parent’s allocation (HALO). This works by using specific attributes that are only available on Clang 20+. You can safely call this function on other compilers but no HALO-specific optimizations will be applied.

Allows you to customize the executor and priority of a subtask without causing an allocation.