Skip to main content

CWakeState

Struct CWakeState 

Source
#[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_void

Opaque pointer passed to fn_ptr on wake.

Implementations§

Source§

impl CWakeState

Source

pub const fn empty() -> Self

Empty / disabled state.

Source

pub fn set(&mut self, fn_ptr: Option<CWakeFn>, ctx: *mut c_void)

Update the callback. Existing Wakers built from self pick up the new value on their next wake — no re-registration needed (the Waker’s data pointer is unchanged).

Trait Implementations§

Source§

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”).

Source§

impl Sync for CWakeState

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.