Skip to content

Commit

Permalink
Clean up RefCell+generic queue
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Dec 6, 2024
1 parent 1cf12d3 commit 6d01c4e
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions esp-hal-embassy/src/timer_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ unsafe impl Sync for TimerQueue {}
impl TimerQueue {
pub(crate) const fn new(prio: Priority) -> Self {
Self {
inner: Mutex::const_new(RawPriorityLimitedMutex::new(prio), adapter::new_queue()),
inner: Mutex::const_new(RawPriorityLimitedMutex::new(prio), RawQueue::new()),
priority: prio,
#[cfg(not(single_queue))]
context: Cell::new(core::ptr::null_mut()),
Expand Down Expand Up @@ -90,10 +90,6 @@ mod adapter {

pub(super) type RawQueue = raw::timer_queue::TimerQueue;

pub(super) const fn new_queue() -> RawQueue {
raw::timer_queue::TimerQueue::new()
}

pub(super) fn dequeue(q: &RawQueue, now: u64) -> u64 {
unsafe { q.next_expiration(now, embassy_executor::raw::wake_task) }
}
Expand All @@ -111,16 +107,10 @@ mod adapter {
mod adapter {
use core::{cell::RefCell, task::Waker};

pub(super) type RawQueue = RefCell<
embassy_time_queue_driver::queue_generic::Queue<
{ esp_config::esp_config_int!(usize, "ESP_HAL_EMBASSY_GENERIC_QUEUE_SIZE") },
>,
pub(super) type RawQueue = embassy_time_queue_driver::queue_generic::RefCellQueue<
{ esp_config::esp_config_int!(usize, "ESP_HAL_EMBASSY_GENERIC_QUEUE_SIZE") },
>;

pub(super) const fn new_queue() -> RawQueue {
RefCell::new(embassy_time_queue_driver::queue_generic::Queue::new())
}

pub(super) fn dequeue(q: &RawQueue, now: u64) -> u64 {
q.borrow_mut().next_expiration(now)
}
Expand Down

0 comments on commit 6d01c4e

Please sign in to comment.