executor: Allow TaskStorage to auto-implement Sync

This commit is contained in:
Grant Miller
2023-03-20 16:20:51 -05:00
parent b6663a013f
commit 41d558a5f4
4 changed files with 154 additions and 57 deletions

View File

@ -1,28 +1,32 @@
use core::cell::Cell;
use core::cmp::min;
use atomic_polyfill::Ordering;
use embassy_time::Instant;
use super::{TaskRef, STATE_TIMER_QUEUED};
use crate::raw::util::SyncUnsafeCell;
pub(crate) struct TimerQueueItem {
next: Cell<Option<TaskRef>>,
next: SyncUnsafeCell<Option<TaskRef>>,
}
impl TimerQueueItem {
pub const fn new() -> Self {
Self { next: Cell::new(None) }
Self {
next: SyncUnsafeCell::new(None),
}
}
}
pub(crate) struct TimerQueue {
head: Cell<Option<TaskRef>>,
head: SyncUnsafeCell<Option<TaskRef>>,
}
impl TimerQueue {
pub const fn new() -> Self {
Self { head: Cell::new(None) }
Self {
head: SyncUnsafeCell::new(None),
}
}
pub(crate) unsafe fn update(&self, p: TaskRef) {