aboutsummaryrefslogtreecommitdiff
path: root/embassy-time/src/queue.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-time/src/queue.rs')
-rw-r--r--embassy-time/src/queue.rs60
1 files changed, 0 insertions, 60 deletions
diff --git a/embassy-time/src/queue.rs b/embassy-time/src/queue.rs
deleted file mode 100644
index d65197c54..000000000
--- a/embassy-time/src/queue.rs
+++ /dev/null
@@ -1,60 +0,0 @@
1//! Timer queue implementation
2//!
3//! This module defines the interface a timer queue needs to implement to power the `embassy_time` module.
4//!
5//! # Implementing a timer queue
6//!
7//! - Define a struct `MyTimerQueue`
8//! - Implement [`TimerQueue`] for it
9//! - Register it as the global timer queue with [`timer_queue_impl`](crate::timer_queue_impl).
10//!
11//! # Linkage details
12//!
13//! Check the documentation of the [`driver`](crate::driver) module for more information.
14//!
15//! Similarly to driver, if there is none or multiple timer queues in the crate tree, linking will fail.
16//!
17//! # Example
18//!
19//! ```
20//! use core::task::Waker;
21//!
22//! use embassy_time::Instant;
23//! use embassy_time::queue::{TimerQueue};
24//!
25//! struct MyTimerQueue{}; // not public!
26//!
27//! impl TimerQueue for MyTimerQueue {
28//! fn schedule_wake(&'static self, at: Instant, waker: &Waker) {
29//! todo!()
30//! }
31//! }
32//! ```
33//! ```ignore
34//! embassy_time::timer_queue_impl!(static QUEUE: MyTimerQueue = MyTimerQueue{});
35//! ```
36use core::task::Waker;
37
38use crate::Instant;
39
40/// Timer queue
41pub trait TimerQueue {
42 /// Schedules a waker in the queue to be awoken at moment `at`.
43 /// If this moment is in the past, the waker might be awoken immediately.
44 fn schedule_wake(&'static self, at: Instant, waker: &Waker);
45}
46
47/// Set the TimerQueue implementation.
48///
49/// See the module documentation for an example.
50#[macro_export]
51macro_rules! timer_queue_impl {
52 (static $name:ident: $t: ty = $val:expr) => {
53 static $name: $t = $val;
54
55 #[no_mangle]
56 fn _embassy_time_schedule_wake(at: $crate::Instant, waker: &core::task::Waker) {
57 <$t as $crate::queue::TimerQueue>::schedule_wake(&$name, at, waker);
58 }
59 };
60}