pub unsafe fn set_stack_allocator(allocator: StackAllocator)Expand description
Register the allocator used for subsequent coroutine Stack allocations.
Platforms whose global allocator places large allocations in external memory that cannot safely back stacks (such as PSRAM on Espressif boards, which is unreachable while writing flash) should call this once during start-up before launching coroutines.
Each Stack stores the deallocate function from the allocator that created it, so
already-live stacks are always released through their matching deallocator even if the
hook is replaced afterwards. Pass StackAllocator::GLOBAL to restore the default
global allocator.
ยงSafety
allocator.allocatemust return either a null pointer or a non-null pointer to an exclusive, writable memory block of at leastlayout.size()bytes aligned tolayout.align().- Any returned memory must remain valid and accessible (including across interrupts and
flash writes on bare-metal targets) until released via
allocator.deallocate. allocator.deallocatemust safely release any non-null pointer returned byallocator.allocatewhen passed the exact matchinglayout.- Both functions must be safe to call from any thread or core that creates or drops a
Stack, without requiring the caller to hold a critical section.