aboutsummaryrefslogtreecommitdiff
path: root/embassy-time-queue-driver/src/lib.rs
diff options
context:
space:
mode:
authorjrmoulton <[email protected]>2025-06-10 15:47:54 -0600
committerjrmoulton <[email protected]>2025-06-10 15:48:36 -0600
commitcfad9798ff99d4de0571a512d156b5fe1ef1d427 (patch)
treefc3bf670f82d139de19466cddad1e909db7f3d2e /embassy-time-queue-driver/src/lib.rs
parentfc342915e6155dec7bafa3e135da7f37a9a07f5c (diff)
parent6186d111a5c150946ee5b7e9e68d987a38c1a463 (diff)
merge new embassy changes
Diffstat (limited to 'embassy-time-queue-driver/src/lib.rs')
-rw-r--r--embassy-time-queue-driver/src/lib.rs60
1 files changed, 0 insertions, 60 deletions
diff --git a/embassy-time-queue-driver/src/lib.rs b/embassy-time-queue-driver/src/lib.rs
deleted file mode 100644
index 50736e8c7..000000000
--- a/embassy-time-queue-driver/src/lib.rs
+++ /dev/null
@@ -1,60 +0,0 @@
1#![no_std]
2#![doc = include_str!("../README.md")]
3#![warn(missing_docs)]
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//! ## Example
12//!
13//! ```
14//! use core::task::Waker;
15//!
16//! use embassy_time::Instant;
17//! use embassy_time::queue::{TimerQueue};
18//!
19//! struct MyTimerQueue{}; // not public!
20//!
21//! impl TimerQueue for MyTimerQueue {
22//! fn schedule_wake(&'static self, at: u64, waker: &Waker) {
23//! todo!()
24//! }
25//! }
26//!
27//! embassy_time_queue_driver::timer_queue_impl!(static QUEUE: MyTimerQueue = MyTimerQueue{});
28//! ```
29use core::task::Waker;
30
31/// Timer queue
32pub trait TimerQueue {
33 /// Schedules a waker in the queue to be awoken at moment `at`.
34 /// If this moment is in the past, the waker might be awoken immediately.
35 fn schedule_wake(&'static self, at: u64, waker: &Waker);
36}
37
38extern "Rust" {
39 fn _embassy_time_schedule_wake(at: u64, waker: &Waker);
40}
41
42/// Schedule the given waker to be woken at `at`.
43pub fn schedule_wake(at: u64, waker: &Waker) {
44 unsafe { _embassy_time_schedule_wake(at, 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: u64, waker: &core::task::Waker) {
57 <$t as $crate::TimerQueue>::schedule_wake(&$name, at, waker);
58 }
59 };
60}