Skip to main content Skip to main content
Pigweed's logo Pigweed
code_xml
  1. Home
  2. Reference
  3. Rust
  4. pw_kernel
  5. kernel
  6. EventSignaler

EventSignaler

Struct EventSignaler 

Source
pub struct EventSignaler<K: Kernel> {
    event: NonNull<Event<K>>,
}
Expand description

A signaler for an Event

EventSignaler is returned from Event::get_signaler() and is used to signal the referenced Event. It can be cloned and the referenced Event will panic if it is dropped when any EventSignalers still reference it.

Fields§

§event: NonNull<Event<K>>

Implementations§

Source§

impl<K: Kernel> EventSignaler<K>

Source

fn event(&self) -> &Event<K>

Source

pub fn signal_and_wake(self)

Signals the Event and wakes any waiting threads, rescheduling if needed.

Consumes the signaler so no references to the event remain before threads are woken, which avoids use-after-free on stack-allocated events.

For long-lived events, the signaler can be cloned to signal multiple times or from multiple threads. It is up to the user to ensure that the Event is only dropped after all signalers are dropped.

§Interrupt context

This method is safe to call in an interrupt context.

Source

pub(crate) fn signal_and_wake_locked<'a>( self, kernel: K, sched: SpinLockGuard<'a, K, SchedulerState<K>>, ) -> SpinLockGuard<'a, K, SchedulerState<K>>

Sets the Event’s state to signaled and wakes waiters while holding the scheduler lock.

Consumes the signaler, matching Self::signal_and_wake.

§Interrupt context

This method is safe to call in an interrupt context.

Source

pub(crate) fn signal_and_dequeue_locked<'a>( self, sched: SpinLockGuard<'a, K, SchedulerState<K>>, wake_list: &mut WakeList<K>, ) -> SpinLockGuard<'a, K, SchedulerState<K>>

Signals the event and dequeues waiters into wake_list without waking them.

Consumes self so no signaler references remain before the caller wakes the threads.

Source

pub fn unsignal(&self)

Sets the Event’s state to un-signaled.

§Interrupt context

This method is safe to call in an interrupt context.

Trait Implementations§

Source§

impl<K: Kernel> Clone for EventSignaler<K>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable)§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K: Kernel> Drop for EventSignaler<K>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<K: Kernel> Send for EventSignaler<K>

Source§

impl<K: Kernel> Sync for EventSignaler<K>

Auto Trait Implementations§

§

impl<K> !RefUnwindSafe for EventSignaler<K>

§

impl<K> !UnwindSafe for EventSignaler<K>

§

impl<K> Forget for EventSignaler<K>

§

impl<K> Freeze for EventSignaler<K>
where NonNull<Event<K>>: Freeze,

§

impl<K> Move for EventSignaler<K>

§

impl<K> Unpin for EventSignaler<K>
where NonNull<Event<K>>: Unpin,

§

impl<K> UnsafeUnpin for EventSignaler<K>
where NonNull<Event<K>>: UnsafeUnpin,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
Source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

Source§

fn cast_into(self) -> U

§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.