boost::capy::get_current_frame_allocator

Return the current frame allocator for this thread.

Synopsis

std::pmr::memory_resource*
get_current_frame_allocator() noexcept;

Description

These accessors exist to implement the allocator propagation portion of the IoAwaitable protocol. Launch functions (run_async, run) set the thread‐local value before invoking a child coroutine; the child's promise_type::operator new reads it to allocate the coroutine frame from the correct resource.

The value is only valid during a narrow execution window. Between a coroutine's resumption and the next suspension point, the protocol guarantees that TLS contains the allocator associated with the currently running chain. Outside that window the value is indeterminate. Only code that implements an IoAwaitable should call these functions.

A return value of nullptr means "not specified" ‐ no allocator has been established for this chain. The awaitable is free to use whatever allocation strategy makes best sense (e.g. std::pmr::new_delete_resource()).

Use of the frame allocator is optional. An awaitable that does not consult this value to allocate its coroutine frame is never wrong. However, a conforming awaitable must still propagate the allocator faithfully so that downstream coroutines can use it.

Return Value

The thread‐local memory_resource pointer, or nullptr if none has been set.

See Also

set_current_frame_allocator, IoAwaitable

Created with MrDocs