Skip to main content

set_core_id_provider

Function set_core_id_provider 

Source
pub unsafe fn set_core_id_provider(provider: CoreIdProvider)
Expand description

Register the platform hook that identifies the calling CPU core on bare metal.

By default, bare-metal targets assume a single core (index 0). Multi-core bare-metal firmware (such as dual-core ESP32-S3 or ESP32-P4) must register a provider once at start-up before any coroutine runs on a secondary core.

On Linux each OS thread already has its own thread-local current-coroutine pointer, so this function is a no-op there.

Panics on bare metal if any coroutine is currently active when called.

ยงSafety

provider must return a unique index in 0..MAX_CORES for each physical CPU core that can execute concurrently, and must be safe to call inside a critical_section without blocking, allocating, or panicking on valid cores.