Skip to main content

Module c_waker

Module c_waker 

Source
Expand description

Phase 122.3.c.6.e — C-ABI-compatible Waker bridge.

Rust’s core::task::Waker is the trait-level event-driven primitive but it isn’t a C-friendly handle (the RawWaker data pointer + vtable layout isn’t exposed across the ABI boundary). Backends that wake via C function pointers can register a CWakeState here, and the make_waker helper builds a Waker that calls back into the C function on wake.

Used by the L1 polling-mode C / C++ FFI to register event-driven callbacks for subscription / service-server / service-client / action server-channel and client-channel events. See nros-c/src/action/server.rs::nros_action_server_set_*_wake_callback for usage.

§Safety

CWakeState must remain at a stable address for the entire lifetime of any Waker (or clone of) built from it. Typical pattern: store it inline in the C handle’s caller-provided _opaque storage so it lives as long as the entity itself.

Structs§

CWakeState
Stable-address storage for a C wake callback. The pointer to this struct is what the Waker holds in its RawWaker::data slot, so it MUST NOT move after a Waker has been built from it.

Functions§

make_waker
Build a Waker that calls state.fn_ptr(state.ctx) on wake.

Type Aliases§

CWakeFn
C function-pointer signature for wake callbacks. Backends call this when the underlying entity has data / a reply / a request pending.