Merge pull request #1563 from kaspar030/interrupt_executor_spawner_fn

embassy-executor: introduce `InterruptExecutor::spawner()`
This commit is contained in:
Dario Nieuwenhuis 2023-06-16 16:00:42 +00:00 committed by GitHub
commit 6ed36cd9c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -205,5 +205,20 @@ mod interrupt {
executor.spawner().make_send() executor.spawner().make_send()
} }
/// Get a SendSpawner for this executor
///
/// This returns a [`SendSpawner`] you can use to spawn tasks on this
/// executor.
///
/// This MUST only be called on an executor that has already been spawned.
/// The function will panic otherwise.
pub fn spawner(&'static self) -> crate::SendSpawner {
if !self.started.load(Ordering::Acquire) {
panic!("InterruptExecutor::spawner() called on uninitialized executor.");
}
let executor = unsafe { (&*self.executor.get()).assume_init_ref() };
executor.spawner().make_send()
}
} }
} }