embassy-executor-timer-queue

Crates

git

Versions

default

Flavors

Skip to main content

Crate embassy_executor_timer_queue

Crate embassy_executor_timer_queue 

Source
Expand description

Timer queue item for embassy-executor integrated timer queues

embassy-executor provides the memory needed to implement integrated timer queues. This crate exists to separate that memory from embassy-executor itself, to decouple the timer queue’s release cycle from embassy-executor.

This crate contains two things:

  • TimerQueueItem: The item type that can be requested from the executor. The size of this type can be configured using the timer-item-size-N-words Cargo features.
  • The TimerQueueItemProvider trait, which must be implemented (by embassy-executor, most likely) to return the TimerQueueItem associated with a given waker. It is a unitrait: the implementation is registered globally with timer_queue_item_provider_impl and resolved at link time.

As a queue implementor, you will need to choose one of the timer-item-size-N-words features to select a queue item size. You can then define your own item type, which must be #[repr(align(8))] (or less) and must fit into the size you selected.

You can access the TimerQueueItem from a Waker using the from_embassy_waker method. You can then use the as_ref and as_mut methods to reinterpret the data stored in the item as your custom item type.

Macros§

timer_queue_item_provider_impl
Register a type as the global TimerQueueItemProvider implementation.

Structs§

TimerQueueItem
The timer queue item provided by the executor.

Traits§

TimerQueueItemProvider
Provider of the TimerQueueItem associated with a waker.

Functions§

item_from_waker
Retrieves the TimerQueueItem reference that belongs to the task of the waker.
try_item_from_waker
Like item_from_waker, but returns None instead of panicking if the waker is not an embassy waker.