diff options
| author | Dániel Buga <[email protected]> | 2024-11-19 14:39:32 +0100 |
|---|---|---|
| committer | Dániel Buga <[email protected]> | 2024-11-19 14:42:41 +0100 |
| commit | ff02ee1a221122ede6e30a94156c42e22b400578 (patch) | |
| tree | b3c0ec30574e5f2da0619299ebf8ebc8ff3189cf /embassy-executor | |
| parent | 0f95c72e78e411e0fd10420ebee3c4bd323a210a (diff) | |
Only set callback once
Diffstat (limited to 'embassy-executor')
| -rw-r--r-- | embassy-executor/CHANGELOG.md | 2 | ||||
| -rw-r--r-- | embassy-executor/src/raw/mod.rs | 12 |
2 files changed, 9 insertions, 5 deletions
diff --git a/embassy-executor/CHANGELOG.md b/embassy-executor/CHANGELOG.md index e07e3924f..eae5e3c2b 100644 --- a/embassy-executor/CHANGELOG.md +++ b/embassy-executor/CHANGELOG.md | |||
| @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
| 7 | 7 | ||
| 8 | ## Unreleased | 8 | ## Unreleased |
| 9 | 9 | ||
| 10 | - Only set integrated-timers callbacks once per executor. | ||
| 11 | |||
| 10 | ## 0.6.3 - 2024-11-12 | 12 | ## 0.6.3 - 2024-11-12 |
| 11 | 13 | ||
| 12 | - Building with the `nightly` feature now works with the Xtensa Rust compiler 1.82. | 14 | - Building with the `nightly` feature now works with the Xtensa Rust compiler 1.82. |
diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs index d9ea5c005..e8a5b8970 100644 --- a/embassy-executor/src/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs | |||
| @@ -328,7 +328,7 @@ impl SyncExecutor { | |||
| 328 | #[cfg(feature = "integrated-timers")] | 328 | #[cfg(feature = "integrated-timers")] |
| 329 | let alarm = unsafe { unwrap!(embassy_time_driver::allocate_alarm()) }; | 329 | let alarm = unsafe { unwrap!(embassy_time_driver::allocate_alarm()) }; |
| 330 | 330 | ||
| 331 | Self { | 331 | let this = Self { |
| 332 | run_queue: RunQueue::new(), | 332 | run_queue: RunQueue::new(), |
| 333 | pender, | 333 | pender, |
| 334 | 334 | ||
| @@ -336,7 +336,12 @@ impl SyncExecutor { | |||
| 336 | timer_queue: timer_queue::TimerQueue::new(), | 336 | timer_queue: timer_queue::TimerQueue::new(), |
| 337 | #[cfg(feature = "integrated-timers")] | 337 | #[cfg(feature = "integrated-timers")] |
| 338 | alarm, | 338 | alarm, |
| 339 | } | 339 | }; |
| 340 | |||
| 341 | #[cfg(feature = "integrated-timers")] | ||
| 342 | embassy_time_driver::set_alarm_callback(this.alarm, Self::alarm_callback, &this as *const _ as *mut ()); | ||
| 343 | |||
| 344 | this | ||
| 340 | } | 345 | } |
| 341 | 346 | ||
| 342 | /// Enqueue a task in the task queue | 347 | /// Enqueue a task in the task queue |
| @@ -374,9 +379,6 @@ impl SyncExecutor { | |||
| 374 | /// | 379 | /// |
| 375 | /// Same as [`Executor::poll`], plus you must only call this on the thread this executor was created. | 380 | /// Same as [`Executor::poll`], plus you must only call this on the thread this executor was created. |
| 376 | pub(crate) unsafe fn poll(&'static self) { | 381 | pub(crate) unsafe fn poll(&'static self) { |
| 377 | #[cfg(feature = "integrated-timers")] | ||
| 378 | embassy_time_driver::set_alarm_callback(self.alarm, Self::alarm_callback, self as *const _ as *mut ()); | ||
| 379 | |||
| 380 | #[allow(clippy::never_loop)] | 382 | #[allow(clippy::never_loop)] |
| 381 | loop { | 383 | loop { |
| 382 | #[cfg(feature = "integrated-timers")] | 384 | #[cfg(feature = "integrated-timers")] |
