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. Event

Event

Struct Event 

Source
pub struct Event<K: Kernel> {
    kernel: K,
    config: EventConfig,
    state: WaitQueueLock<K, EventState>,
    signalers: K::AtomicUsize,
}
Expand description

A basic synchronization primitive allowing threads to block on an event happening.

An Event starts in an un-signaled state. Threads can use wait or wait_until to block until the state has changed to signaled. The signal state is controlled by an EventSignaler via the signal_and_wake and unsignal methods.

Depending on what EventConfig is used, signal_and_wake may either set the signal permanently, or it may be automatically cleared once a single waiter has been un-blocked by it.

§Panics

Panics on drop if there are EventSignalers referencing this object.

Fields§

§kernel: K§config: EventConfig§state: WaitQueueLock<K, EventState>§signalers: K::AtomicUsize

Implementations§

Source§

impl<K: Kernel> Event<K>

Source

pub const fn new(kernel: K, config: EventConfig) -> Self

Constructs a new Event with the given configuration.

Source

pub fn get_signaler(&self) -> EventSignaler<K>

Returns an EventSignaler for signaling an Event.

Source

pub fn wait(&self) -> Result<()>

Waits until the Event is in the signaled state.

If the event’s configuration is AutoReset, the thread which is un-blocked by a signal also clears that signal, resetting its value to un-signaled.

§Interrupt context

This method is not safe to call in an interrupt context.

Source

pub fn wait_until(&self, deadline: Instant<K::Clock>) -> Result<()>

Waits until the Event is in the signaled state or the deadline is reached, whichever happens first.

If the event’s configuration is EventConfig::AutoReset, the thread which is un-blocked by a signal also clears that signal, resetting its value to un-signaled.

§Interrupt context

This method is not safe to call in an interrupt context.

Source

fn signal_locked_dequeue<'lock, 'sched>( &self, state: WaitQueueLockGuard<'lock, 'sched, K, EventState>, wake_list: &mut WakeList<K>, ) -> WaitQueueLockGuard<'lock, 'sched, K, EventState>

Updates the event’s state and dequeues its waiters into wake_list without waking them.

Source

fn unsignal(&self)

Trait Implementations§

Source§

impl<K: Kernel> Drop for Event<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 Event<K>

Source§

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

Auto Trait Implementations§

§

impl<K> !Freeze for Event<K>

§

impl<K> !RefUnwindSafe for Event<K>

§

impl<K> !Unpin for Event<K>

§

impl<K> !UnwindSafe for Event<K>

§

impl<K> Forget for Event<K>

§

impl<K> Move for Event<K>

§

impl<K> UnsafeUnpin for Event<K>
where K: UnsafeUnpin, WaitQueueLock<K, EventState>: UnsafeUnpin, <K as Arch>::AtomicUsize: 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> 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.