aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor/src/raw/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-executor/src/raw/mod.rs')
-rw-r--r--embassy-executor/src/raw/mod.rs19
1 files changed, 16 insertions, 3 deletions
diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs
index d9ea5c005..ebabee1ba 100644
--- a/embassy-executor/src/raw/mod.rs
+++ b/embassy-executor/src/raw/mod.rs
@@ -339,6 +339,11 @@ impl SyncExecutor {
339 } 339 }
340 } 340 }
341 341
342 pub(crate) unsafe fn initialize(&'static self) {
343 #[cfg(feature = "integrated-timers")]
344 embassy_time_driver::set_alarm_callback(self.alarm, Self::alarm_callback, self as *const _ as *mut ());
345 }
346
342 /// Enqueue a task in the task queue 347 /// Enqueue a task in the task queue
343 /// 348 ///
344 /// # Safety 349 /// # Safety
@@ -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")]
@@ -492,6 +494,15 @@ impl Executor {
492 } 494 }
493 } 495 }
494 496
497 /// Initializes the executor.
498 ///
499 /// # Safety
500 ///
501 /// This function must be called once before any other method is called.
502 pub unsafe fn initialize(&'static self) {
503 self.inner.initialize();
504 }
505
495 /// Spawn a task in this executor. 506 /// Spawn a task in this executor.
496 /// 507 ///
497 /// # Safety 508 /// # Safety
@@ -516,6 +527,8 @@ impl Executor {
516 /// 527 ///
517 /// # Safety 528 /// # Safety
518 /// 529 ///
530 /// You must call `initialize` before calling this method.
531 ///
519 /// You must NOT call `poll` reentrantly on the same executor. 532 /// You must NOT call `poll` reentrantly on the same executor.
520 /// 533 ///
521 /// In particular, note that `poll` may call the pender synchronously. Therefore, you 534 /// In particular, note that `poll` may call the pender synchronously. Therefore, you