aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor/src/raw/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-executor/src/raw/mod.rs')
-rw-r--r--embassy-executor/src/raw/mod.rs27
1 files changed, 13 insertions, 14 deletions
diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs
index b16a1c7c3..3f00be4a8 100644
--- a/embassy-executor/src/raw/mod.rs
+++ b/embassy-executor/src/raw/mod.rs
@@ -30,9 +30,7 @@ use core::ptr::NonNull;
30use core::task::{Context, Poll}; 30use core::task::{Context, Poll};
31 31
32#[cfg(feature = "integrated-timers")] 32#[cfg(feature = "integrated-timers")]
33use embassy_time::driver::{self, AlarmHandle}; 33use embassy_time_driver::{self, AlarmHandle};
34#[cfg(feature = "integrated-timers")]
35use embassy_time::Instant;
36#[cfg(feature = "rtos-trace")] 34#[cfg(feature = "rtos-trace")]
37use rtos_trace::trace; 35use rtos_trace::trace;
38 36
@@ -50,7 +48,7 @@ pub(crate) struct TaskHeader {
50 poll_fn: SyncUnsafeCell<Option<unsafe fn(TaskRef)>>, 48 poll_fn: SyncUnsafeCell<Option<unsafe fn(TaskRef)>>,
51 49
52 #[cfg(feature = "integrated-timers")] 50 #[cfg(feature = "integrated-timers")]
53 pub(crate) expires_at: SyncUnsafeCell<Instant>, 51 pub(crate) expires_at: SyncUnsafeCell<u64>,
54 #[cfg(feature = "integrated-timers")] 52 #[cfg(feature = "integrated-timers")]
55 pub(crate) timer_queue_item: timer_queue::TimerQueueItem, 53 pub(crate) timer_queue_item: timer_queue::TimerQueueItem,
56} 54}
@@ -123,7 +121,7 @@ impl<F: Future + 'static> TaskStorage<F> {
123 poll_fn: SyncUnsafeCell::new(None), 121 poll_fn: SyncUnsafeCell::new(None),
124 122
125 #[cfg(feature = "integrated-timers")] 123 #[cfg(feature = "integrated-timers")]
126 expires_at: SyncUnsafeCell::new(Instant::from_ticks(0)), 124 expires_at: SyncUnsafeCell::new(0),
127 #[cfg(feature = "integrated-timers")] 125 #[cfg(feature = "integrated-timers")]
128 timer_queue_item: timer_queue::TimerQueueItem::new(), 126 timer_queue_item: timer_queue::TimerQueueItem::new(),
129 }, 127 },
@@ -164,7 +162,7 @@ impl<F: Future + 'static> TaskStorage<F> {
164 this.raw.state.despawn(); 162 this.raw.state.despawn();
165 163
166 #[cfg(feature = "integrated-timers")] 164 #[cfg(feature = "integrated-timers")]
167 this.raw.expires_at.set(Instant::MAX); 165 this.raw.expires_at.set(u64::MAX);
168 } 166 }
169 Poll::Pending => {} 167 Poll::Pending => {}
170 } 168 }
@@ -328,7 +326,7 @@ pub(crate) struct SyncExecutor {
328impl SyncExecutor { 326impl SyncExecutor {
329 pub(crate) fn new(pender: Pender) -> Self { 327 pub(crate) fn new(pender: Pender) -> Self {
330 #[cfg(feature = "integrated-timers")] 328 #[cfg(feature = "integrated-timers")]
331 let alarm = unsafe { unwrap!(driver::allocate_alarm()) }; 329 let alarm = unsafe { unwrap!(embassy_time_driver::allocate_alarm()) };
332 330
333 Self { 331 Self {
334 run_queue: RunQueue::new(), 332 run_queue: RunQueue::new(),
@@ -377,18 +375,19 @@ impl SyncExecutor {
377 /// Same as [`Executor::poll`], plus you must only call this on the thread this executor was created. 375 /// Same as [`Executor::poll`], plus you must only call this on the thread this executor was created.
378 pub(crate) unsafe fn poll(&'static self) { 376 pub(crate) unsafe fn poll(&'static self) {
379 #[cfg(feature = "integrated-timers")] 377 #[cfg(feature = "integrated-timers")]
380 driver::set_alarm_callback(self.alarm, Self::alarm_callback, self as *const _ as *mut ()); 378 embassy_time_driver::set_alarm_callback(self.alarm, Self::alarm_callback, self as *const _ as *mut ());
381 379
382 #[allow(clippy::never_loop)] 380 #[allow(clippy::never_loop)]
383 loop { 381 loop {
384 #[cfg(feature = "integrated-timers")] 382 #[cfg(feature = "integrated-timers")]
385 self.timer_queue.dequeue_expired(Instant::now(), wake_task_no_pend); 383 self.timer_queue
384 .dequeue_expired(embassy_time_driver::now(), wake_task_no_pend);
386 385
387 self.run_queue.dequeue_all(|p| { 386 self.run_queue.dequeue_all(|p| {
388 let task = p.header(); 387 let task = p.header();
389 388
390 #[cfg(feature = "integrated-timers")] 389 #[cfg(feature = "integrated-timers")]
391 task.expires_at.set(Instant::MAX); 390 task.expires_at.set(u64::MAX);
392 391
393 if !task.state.run_dequeue() { 392 if !task.state.run_dequeue() {
394 // If task is not running, ignore it. This can happen in the following scenario: 393 // If task is not running, ignore it. This can happen in the following scenario:
@@ -418,7 +417,7 @@ impl SyncExecutor {
418 // If this is already in the past, set_alarm might return false 417 // If this is already in the past, set_alarm might return false
419 // In that case do another poll loop iteration. 418 // In that case do another poll loop iteration.
420 let next_expiration = self.timer_queue.next_expiration(); 419 let next_expiration = self.timer_queue.next_expiration();
421 if driver::set_alarm(self.alarm, next_expiration.as_ticks()) { 420 if embassy_time_driver::set_alarm(self.alarm, next_expiration) {
422 break; 421 break;
423 } 422 }
424 } 423 }
@@ -568,8 +567,8 @@ pub fn wake_task_no_pend(task: TaskRef) {
568struct TimerQueue; 567struct TimerQueue;
569 568
570#[cfg(feature = "integrated-timers")] 569#[cfg(feature = "integrated-timers")]
571impl embassy_time::queue::TimerQueue for TimerQueue { 570impl embassy_time_queue_driver::TimerQueue for TimerQueue {
572 fn schedule_wake(&'static self, at: Instant, waker: &core::task::Waker) { 571 fn schedule_wake(&'static self, at: u64, waker: &core::task::Waker) {
573 let task = waker::task_from_waker(waker); 572 let task = waker::task_from_waker(waker);
574 let task = task.header(); 573 let task = task.header();
575 unsafe { 574 unsafe {
@@ -580,7 +579,7 @@ impl embassy_time::queue::TimerQueue for TimerQueue {
580} 579}
581 580
582#[cfg(feature = "integrated-timers")] 581#[cfg(feature = "integrated-timers")]
583embassy_time::timer_queue_impl!(static TIMER_QUEUE: TimerQueue = TimerQueue); 582embassy_time_queue_driver::timer_queue_impl!(static TIMER_QUEUE: TimerQueue = TimerQueue);
584 583
585#[cfg(feature = "rtos-trace")] 584#[cfg(feature = "rtos-trace")]
586impl rtos_trace::RtosTraceOSCallbacks for Executor { 585impl rtos_trace::RtosTraceOSCallbacks for Executor {