aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor/src
diff options
context:
space:
mode:
authorDániel Buga <[email protected]>2024-11-19 14:39:32 +0100
committerDániel Buga <[email protected]>2024-11-19 14:42:41 +0100
commitff02ee1a221122ede6e30a94156c42e22b400578 (patch)
treeb3c0ec30574e5f2da0619299ebf8ebc8ff3189cf /embassy-executor/src
parent0f95c72e78e411e0fd10420ebee3c4bd323a210a (diff)
Only set callback once
Diffstat (limited to 'embassy-executor/src')
-rw-r--r--embassy-executor/src/raw/mod.rs12
1 files changed, 7 insertions, 5 deletions
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")]