Only set callback once

This commit is contained in:
Dániel Buga 2024-11-19 14:39:32 +01:00
parent 0f95c72e78
commit ff02ee1a22
No known key found for this signature in database
2 changed files with 9 additions and 5 deletions

View File

@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased ## Unreleased
- Only set integrated-timers callbacks once per executor.
## 0.6.3 - 2024-11-12 ## 0.6.3 - 2024-11-12
- Building with the `nightly` feature now works with the Xtensa Rust compiler 1.82. - Building with the `nightly` feature now works with the Xtensa Rust compiler 1.82.

View File

@ -328,7 +328,7 @@ impl SyncExecutor {
#[cfg(feature = "integrated-timers")] #[cfg(feature = "integrated-timers")]
let alarm = unsafe { unwrap!(embassy_time_driver::allocate_alarm()) }; let alarm = unsafe { unwrap!(embassy_time_driver::allocate_alarm()) };
Self { let this = Self {
run_queue: RunQueue::new(), run_queue: RunQueue::new(),
pender, pender,
@ -336,7 +336,12 @@ impl SyncExecutor {
timer_queue: timer_queue::TimerQueue::new(), timer_queue: timer_queue::TimerQueue::new(),
#[cfg(feature = "integrated-timers")] #[cfg(feature = "integrated-timers")]
alarm, alarm,
} };
#[cfg(feature = "integrated-timers")]
embassy_time_driver::set_alarm_callback(this.alarm, Self::alarm_callback, &this as *const _ as *mut ());
this
} }
/// Enqueue a task in the task queue /// Enqueue a task in the task queue
@ -374,9 +379,6 @@ impl SyncExecutor {
/// ///
/// Same as [`Executor::poll`], plus you must only call this on the thread this executor was created. /// Same as [`Executor::poll`], plus you must only call this on the thread this executor was created.
pub(crate) unsafe fn poll(&'static self) { pub(crate) unsafe fn poll(&'static self) {
#[cfg(feature = "integrated-timers")]
embassy_time_driver::set_alarm_callback(self.alarm, Self::alarm_callback, self as *const _ as *mut ());
#[allow(clippy::never_loop)] #[allow(clippy::never_loop)]
loop { loop {
#[cfg(feature = "integrated-timers")] #[cfg(feature = "integrated-timers")]