#[repr(C)]pub struct CWakeState {
pub fn_ptr: Option<CWakeFn>,
pub ctx: *mut c_void,
}Expand description
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.
Fields§
§fn_ptr: Option<CWakeFn>Function called when the Waker is woken. None disables.
ctx: *mut c_voidOpaque pointer passed to fn_ptr on wake.
Implementations§
Source§impl CWakeState
impl CWakeState
Trait Implementations§
impl Send for CWakeState
SAFETY: CWakeState holds a function pointer (Send/Sync) +
an opaque user ctx pointer (no auto-impl). For the wake path
to be sound across threads the C caller must ensure the
underlying object behind ctx is reachable from whatever thread
the backend dispatches the wake callback on. By marking the
state as Send+Sync we let backends (e.g. AtomicWaker) stash
the Waker in shared state; the C contract is documented at the
FFI surface (“the C ctx must outlive every wake-callback
invocation and be safe to read from any thread the runtime
dispatches wakes on”).