Skip to content

Commit

Permalink
Don't take CS if the task didn't re-schedule itself
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Nov 28, 2024
1 parent 457e708 commit dcc2c29
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions embassy-executor/src/raw/timer_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ impl TimerQueue {

pub(crate) unsafe fn update(&self, p: TaskRef) {
let task = p.header();
critical_section::with(|cs| {
task.expires_at.borrow(cs).set(task.next_expiration.get());
if task.next_expiration.get() != u64::MAX {
if task.next_expiration.get() != u64::MAX {
critical_section::with(|cs| {
if task.state.timer_enqueue() {
let prev = self.head.borrow(cs).replace(Some(p));
task.timer_queue_item.next.borrow(cs).set(prev);
}
}
});
});
}
}

pub(crate) unsafe fn next_expiration(&self) -> u64 {
let mut res = u64::MAX;
critical_section::with(|cs| {
self.retain(cs, |p| {
let task = p.header();
let expires = task.expires_at.borrow(cs).get();
let expires = task.next_expiration.get();
task.expires_at.borrow(cs).set(expires);
res = min(res, expires);
expires != u64::MAX
});
Expand Down

0 comments on commit dcc2c29

Please sign in to comment.