aboutsummaryrefslogtreecommitdiff
path: root/embassy-time-queue-driver
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2024-12-17 14:52:12 +0100
committerGitHub <[email protected]>2024-12-17 14:52:12 +0100
commitc504ae8d3a5eb754e0b0920b346dd1a2dc9e2b48 (patch)
treedfc3ac53ba9ffd270dc3d4e8b5a3d3daec3c3611 /embassy-time-queue-driver
parent9cf037bc954cc347b5d52d90207f68090cc5b09e (diff)
parentc3c571e01ef902ccd2c3b176a4bc6ee3547d5da7 (diff)
Merge pull request #3656 from bugadani/timer-queue-special
Remove special handling of integrated timer queues and items
Diffstat (limited to 'embassy-time-queue-driver')
-rw-r--r--embassy-time-queue-driver/src/lib.rs28
-rw-r--r--embassy-time-queue-driver/src/queue_integrated.rs1
2 files changed, 0 insertions, 29 deletions
diff --git a/embassy-time-queue-driver/src/lib.rs b/embassy-time-queue-driver/src/lib.rs
index 97c81a124..333b6124d 100644
--- a/embassy-time-queue-driver/src/lib.rs
+++ b/embassy-time-queue-driver/src/lib.rs
@@ -10,8 +10,6 @@
10//! As a HAL implementer, you need to depend on this crate if you want to implement a time driver, 10//! As a HAL implementer, you need to depend on this crate if you want to implement a time driver,
11//! but how you should do so is documented in `embassy-time-driver`. 11//! but how you should do so is documented in `embassy-time-driver`.
12 12
13use core::task::Waker;
14
15#[cfg(feature = "_generic-queue")] 13#[cfg(feature = "_generic-queue")]
16pub mod queue_generic; 14pub mod queue_generic;
17#[cfg(not(feature = "_generic-queue"))] 15#[cfg(not(feature = "_generic-queue"))]
@@ -21,29 +19,3 @@ pub mod queue_integrated;
21pub use queue_generic::Queue; 19pub use queue_generic::Queue;
22#[cfg(not(feature = "_generic-queue"))] 20#[cfg(not(feature = "_generic-queue"))]
23pub use queue_integrated::Queue; 21pub use queue_integrated::Queue;
24
25extern "Rust" {
26 fn _embassy_time_schedule_wake(at: u64, waker: &Waker);
27}
28
29/// Schedule the given waker to be woken at `at`.
30pub fn schedule_wake(at: u64, waker: &Waker) {
31 // This function is not implemented in embassy-time-driver because it needs access to executor
32 // internals. The function updates task state, then delegates to the implementation provided
33 // by the time driver.
34 #[cfg(not(feature = "_generic-queue"))]
35 {
36 use embassy_executor::raw::task_from_waker;
37 use embassy_executor::raw::timer_queue::TimerEnqueueOperation;
38 // The very first thing we must do, before we even access the timer queue, is to
39 // mark the task a TIMER_QUEUED. This ensures that the task that is being scheduled
40 // can not be respawn while we are accessing the timer queue.
41 let task = task_from_waker(waker);
42 if unsafe { task.timer_enqueue() } == TimerEnqueueOperation::Ignore {
43 // We are not allowed to enqueue the task in the timer queue. This is because the
44 // task is not spawned, and so it makes no sense to schedule it.
45 return;
46 }
47 }
48 unsafe { _embassy_time_schedule_wake(at, waker) }
49}
diff --git a/embassy-time-queue-driver/src/queue_integrated.rs b/embassy-time-queue-driver/src/queue_integrated.rs
index 6bb4c0c1a..246cf1d63 100644
--- a/embassy-time-queue-driver/src/queue_integrated.rs
+++ b/embassy-time-queue-driver/src/queue_integrated.rs
@@ -83,7 +83,6 @@ impl Queue {
83 // Remove it 83 // Remove it
84 prev.set(item.next.get()); 84 prev.set(item.next.get());
85 item.next.set(None); 85 item.next.set(None);
86 unsafe { p.timer_dequeue() };
87 } 86 }
88 } 87 }
89 } 88 }