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::AtomicUsizeImplementations§
Source§impl<K: Kernel> Event<K>
impl<K: Kernel> Event<K>
Sourcepub const fn new(kernel: K, config: EventConfig) -> Self
pub const fn new(kernel: K, config: EventConfig) -> Self
Constructs a new Event with the given configuration.
Sourcepub fn get_signaler(&self) -> EventSignaler<K>
pub fn get_signaler(&self) -> EventSignaler<K>
Returns an EventSignaler for signaling an Event.
Sourcepub fn wait_until(&self, deadline: Instant<K::Clock>) -> Result<()>
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.
Sourcefn signal_locked_dequeue<'lock, 'sched>(
&self,
state: WaitQueueLockGuard<'lock, 'sched, K, EventState>,
wake_list: &mut WakeList<K>,
) -> WaitQueueLockGuard<'lock, 'sched, K, EventState>
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.