pub struct Queue { /* private fields */ }Expand description
A timer queue, with items integrated into tasks.
§Safety
This Queue is only safe when there is a single integrated queue in the system.
If there are multiple integrated queues, additional checks are necessary to ensure that a Waker is not attempted to be enqueued in multiple queues.
Implementations§
Source§impl Queue
impl Queue
Sourcepub fn schedule_wake(&mut self, at: u64, waker: &Waker) -> bool
pub fn schedule_wake(&mut self, at: u64, waker: &Waker) -> bool
Schedules a task to run at a specific time.
If this function returns true, the caller should find the next expiration time and set
a new alarm for that time.
Sourcepub fn schedule_wake_queue_item(
&mut self,
at: u64,
item: &mut TimerQueueItem,
waker: &Waker,
) -> bool
pub fn schedule_wake_queue_item( &mut self, at: u64, item: &mut TimerQueueItem, waker: &Waker, ) -> bool
Schedules a task to run at a specific time, using a timer queue item as storage.
If this function returns true, the caller should find the next expiration time and set
a new alarm for that time.
This function assumes that the timer queue item is associated with the provided waker.
It can be used to support cases where there may not be an embassy task behind the waker.
One such case is integration with other async runtimes, be it a simple block_on
implementation or something more complex.
Sourcepub fn next_expiration(&mut self, now: u64) -> u64
pub fn next_expiration(&mut self, now: u64) -> u64
Dequeues expired timers and returns the next alarm time.
The provided callback will be called for each expired task. Tasks that never expire will be removed, but the callback will not be called.