aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor/src/raw/mod.rs
diff options
context:
space:
mode:
authorDániel Buga <[email protected]>2024-11-19 15:59:31 +0100
committerDániel Buga <[email protected]>2024-11-19 16:25:17 +0100
commit8ebe059ecb311ee949f92dde33f2cb8d972b0f7b (patch)
tree4906d12e2a2f141dded4defd84650b165e2da51d /embassy-executor/src/raw/mod.rs
parentff02ee1a221122ede6e30a94156c42e22b400578 (diff)
Add initialize
Diffstat (limited to 'embassy-executor/src/raw/mod.rs')
-rw-r--r--embassy-executor/src/raw/mod.rs21
1 files changed, 16 insertions, 5 deletions
diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs
index e8a5b8970..ebabee1ba 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 let this = Self { 331 Self {
332 run_queue: RunQueue::new(), 332 run_queue: RunQueue::new(),
333 pender, 333 pender,
334 334
@@ -336,12 +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 }
340 341
342 pub(crate) unsafe fn initialize(&'static self) {
341 #[cfg(feature = "integrated-timers")] 343 #[cfg(feature = "integrated-timers")]
342 embassy_time_driver::set_alarm_callback(this.alarm, Self::alarm_callback, &this as *const _ as *mut ()); 344 embassy_time_driver::set_alarm_callback(self.alarm, Self::alarm_callback, self as *const _ as *mut ());
343
344 this
345 } 345 }
346 346
347 /// Enqueue a task in the task queue 347 /// Enqueue a task in the task queue
@@ -494,6 +494,15 @@ impl Executor {
494 } 494 }
495 } 495 }
496 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
497 /// Spawn a task in this executor. 506 /// Spawn a task in this executor.
498 /// 507 ///
499 /// # Safety 508 /// # Safety
@@ -518,6 +527,8 @@ impl Executor {
518 /// 527 ///
519 /// # Safety 528 /// # Safety
520 /// 529 ///
530 /// You must call `initialize` before calling this method.
531 ///
521 /// You must NOT call `poll` reentrantly on the same executor. 532 /// You must NOT call `poll` reentrantly on the same executor.
522 /// 533 ///
523 /// 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