From 3db8655e25bf40d0f0b72e557a8d6e3d156119c8 Mon Sep 17 00:00:00 2001 From: Chris Price Date: Tue, 9 Jan 2024 17:36:39 +0000 Subject: Ignore the doctest driver registration to prevent duplicate registrations --- embassy-time/src/queue.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'embassy-time/src/queue.rs') diff --git a/embassy-time/src/queue.rs b/embassy-time/src/queue.rs index c6f8b440a..d65197c54 100644 --- a/embassy-time/src/queue.rs +++ b/embassy-time/src/queue.rs @@ -23,7 +23,6 @@ //! use embassy_time::queue::{TimerQueue}; //! //! struct MyTimerQueue{}; // not public! -//! embassy_time::timer_queue_impl!(static QUEUE: MyTimerQueue = MyTimerQueue{}); //! //! impl TimerQueue for MyTimerQueue { //! fn schedule_wake(&'static self, at: Instant, waker: &Waker) { @@ -31,6 +30,9 @@ //! } //! } //! ``` +//! ```ignore +//! embassy_time::timer_queue_impl!(static QUEUE: MyTimerQueue = MyTimerQueue{}); +//! ``` use core::task::Waker; use crate::Instant; -- cgit From f0606da9adc8032cc92c06c0661b385742459fc8 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Thu, 11 Jan 2024 22:47:05 +0100 Subject: time: split queue driver too, don't reexport drivers. --- embassy-time/src/queue.rs | 60 ----------------------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 embassy-time/src/queue.rs (limited to 'embassy-time/src/queue.rs') 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 @@ -//! Timer queue implementation -//! -//! This module defines the interface a timer queue needs to implement to power the `embassy_time` module. -//! -//! # Implementing a timer queue -//! -//! - Define a struct `MyTimerQueue` -//! - Implement [`TimerQueue`] for it -//! - Register it as the global timer queue with [`timer_queue_impl`](crate::timer_queue_impl). -//! -//! # Linkage details -//! -//! Check the documentation of the [`driver`](crate::driver) module for more information. -//! -//! Similarly to driver, if there is none or multiple timer queues in the crate tree, linking will fail. -//! -//! # Example -//! -//! ``` -//! use core::task::Waker; -//! -//! use embassy_time::Instant; -//! use embassy_time::queue::{TimerQueue}; -//! -//! struct MyTimerQueue{}; // not public! -//! -//! impl TimerQueue for MyTimerQueue { -//! fn schedule_wake(&'static self, at: Instant, waker: &Waker) { -//! todo!() -//! } -//! } -//! ``` -//! ```ignore -//! embassy_time::timer_queue_impl!(static QUEUE: MyTimerQueue = MyTimerQueue{}); -//! ``` -use core::task::Waker; - -use crate::Instant; - -/// Timer queue -pub trait TimerQueue { - /// Schedules a waker in the queue to be awoken at moment `at`. - /// If this moment is in the past, the waker might be awoken immediately. - fn schedule_wake(&'static self, at: Instant, waker: &Waker); -} - -/// Set the TimerQueue implementation. -/// -/// See the module documentation for an example. -#[macro_export] -macro_rules! timer_queue_impl { - (static $name:ident: $t: ty = $val:expr) => { - static $name: $t = $val; - - #[no_mangle] - fn _embassy_time_schedule_wake(at: $crate::Instant, waker: &core::task::Waker) { - <$t as $crate::queue::TimerQueue>::schedule_wake(&$name, at, waker); - } - }; -} -- cgit