diff options
| author | Frostie314159 <[email protected]> | 2024-03-31 20:48:05 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-03-31 20:48:05 +0200 |
| commit | 67c9cc2c4b886e6962ecdd6eff8794b14c1accdc (patch) | |
| tree | f176ab269949d26f48e04c950cebc5489bae8c56 /embassy-executor/src/raw/timer_queue.rs | |
| parent | a2f9aa592ec61beb247065003016515f0d423c13 (diff) | |
| parent | 6634cc90bcd3eb25b64712688920f383584b2964 (diff) | |
Merge branch 'embassy-rs:main' into ticker_send_sync
Diffstat (limited to 'embassy-executor/src/raw/timer_queue.rs')
| -rw-r--r-- | embassy-executor/src/raw/timer_queue.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/embassy-executor/src/raw/timer_queue.rs b/embassy-executor/src/raw/timer_queue.rs index 59a3b43f5..94a5f340b 100644 --- a/embassy-executor/src/raw/timer_queue.rs +++ b/embassy-executor/src/raw/timer_queue.rs | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | use core::cmp::min; | 1 | use core::cmp::min; |
| 2 | 2 | ||
| 3 | use embassy_time::Instant; | ||
| 4 | |||
| 5 | use super::TaskRef; | 3 | use super::TaskRef; |
| 6 | use crate::raw::util::SyncUnsafeCell; | 4 | use crate::raw::util::SyncUnsafeCell; |
| 7 | 5 | ||
| @@ -30,7 +28,7 @@ impl TimerQueue { | |||
| 30 | 28 | ||
| 31 | pub(crate) unsafe fn update(&self, p: TaskRef) { | 29 | pub(crate) unsafe fn update(&self, p: TaskRef) { |
| 32 | let task = p.header(); | 30 | let task = p.header(); |
| 33 | if task.expires_at.get() != Instant::MAX { | 31 | if task.expires_at.get() != u64::MAX { |
| 34 | if task.state.timer_enqueue() { | 32 | if task.state.timer_enqueue() { |
| 35 | task.timer_queue_item.next.set(self.head.get()); | 33 | task.timer_queue_item.next.set(self.head.get()); |
| 36 | self.head.set(Some(p)); | 34 | self.head.set(Some(p)); |
| @@ -38,18 +36,18 @@ impl TimerQueue { | |||
| 38 | } | 36 | } |
| 39 | } | 37 | } |
| 40 | 38 | ||
| 41 | pub(crate) unsafe fn next_expiration(&self) -> Instant { | 39 | pub(crate) unsafe fn next_expiration(&self) -> u64 { |
| 42 | let mut res = Instant::MAX; | 40 | let mut res = u64::MAX; |
| 43 | self.retain(|p| { | 41 | self.retain(|p| { |
| 44 | let task = p.header(); | 42 | let task = p.header(); |
| 45 | let expires = task.expires_at.get(); | 43 | let expires = task.expires_at.get(); |
| 46 | res = min(res, expires); | 44 | res = min(res, expires); |
| 47 | expires != Instant::MAX | 45 | expires != u64::MAX |
| 48 | }); | 46 | }); |
| 49 | res | 47 | res |
| 50 | } | 48 | } |
| 51 | 49 | ||
| 52 | pub(crate) unsafe fn dequeue_expired(&self, now: Instant, on_task: impl Fn(TaskRef)) { | 50 | pub(crate) unsafe fn dequeue_expired(&self, now: u64, on_task: impl Fn(TaskRef)) { |
| 53 | self.retain(|p| { | 51 | self.retain(|p| { |
| 54 | let task = p.header(); | 52 | let task = p.header(); |
| 55 | if task.expires_at.get() <= now { | 53 | if task.expires_at.get() <= now { |
