diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2023-03-26 22:23:00 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-03-26 22:23:00 +0000 |
| commit | 8a3a7c65a89e27883a2ab7524162f26851c4c10a (patch) | |
| tree | 47ad806df2a2a05f874cff215c2c3f1cd0a088d4 /embassy-executor/src/raw/timer_queue.rs | |
| parent | 7186e038012bf8c3430334c4838cb8ff508040b1 (diff) | |
| parent | 21400da073d7173e4c2445cbbcd2cd430f120ad1 (diff) | |
Merge #1291
1291: executor: Allow TaskStorage to auto-implement `Sync` r=Dirbaio a=GrantM11235
Co-authored-by: Grant Miller <[email protected]>
Co-authored-by: Dario Nieuwenhuis <[email protected]>
Diffstat (limited to 'embassy-executor/src/raw/timer_queue.rs')
| -rw-r--r-- | embassy-executor/src/raw/timer_queue.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/embassy-executor/src/raw/timer_queue.rs b/embassy-executor/src/raw/timer_queue.rs index 57d6d3cda..dc71c95b1 100644 --- a/embassy-executor/src/raw/timer_queue.rs +++ b/embassy-executor/src/raw/timer_queue.rs | |||
| @@ -1,28 +1,32 @@ | |||
| 1 | use core::cell::Cell; | ||
| 2 | use core::cmp::min; | 1 | use core::cmp::min; |
| 3 | 2 | ||
| 4 | use atomic_polyfill::Ordering; | 3 | use atomic_polyfill::Ordering; |
| 5 | use embassy_time::Instant; | 4 | use embassy_time::Instant; |
| 6 | 5 | ||
| 7 | use super::{TaskRef, STATE_TIMER_QUEUED}; | 6 | use super::{TaskRef, STATE_TIMER_QUEUED}; |
| 7 | use crate::raw::util::SyncUnsafeCell; | ||
| 8 | 8 | ||
| 9 | pub(crate) struct TimerQueueItem { | 9 | pub(crate) struct TimerQueueItem { |
| 10 | next: Cell<Option<TaskRef>>, | 10 | next: SyncUnsafeCell<Option<TaskRef>>, |
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | impl TimerQueueItem { | 13 | impl TimerQueueItem { |
| 14 | pub const fn new() -> Self { | 14 | pub const fn new() -> Self { |
| 15 | Self { next: Cell::new(None) } | 15 | Self { |
| 16 | next: SyncUnsafeCell::new(None), | ||
| 17 | } | ||
| 16 | } | 18 | } |
| 17 | } | 19 | } |
| 18 | 20 | ||
| 19 | pub(crate) struct TimerQueue { | 21 | pub(crate) struct TimerQueue { |
| 20 | head: Cell<Option<TaskRef>>, | 22 | head: SyncUnsafeCell<Option<TaskRef>>, |
| 21 | } | 23 | } |
| 22 | 24 | ||
| 23 | impl TimerQueue { | 25 | impl TimerQueue { |
| 24 | pub const fn new() -> Self { | 26 | pub const fn new() -> Self { |
| 25 | Self { head: Cell::new(None) } | 27 | Self { |
| 28 | head: SyncUnsafeCell::new(None), | ||
| 29 | } | ||
| 26 | } | 30 | } |
| 27 | 31 | ||
| 28 | pub(crate) unsafe fn update(&self, p: TaskRef) { | 32 | pub(crate) unsafe fn update(&self, p: TaskRef) { |
