embassy: introduce InterruptExecutor::spawner() (#1211)

Co-authored-by: Jesse Braham <jessebraham@users.noreply.github.com>
This commit is contained in:
Kaspar Schleiser 2024-02-28 18:15:52 +01:00 committed by GitHub
parent e81957ee98
commit 3ec0f3b8ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 0 deletions

View File

@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added basic `LP-I2C` driver for C6 (#1185)
- Ensuring that the random number generator is TRNG. (#1200)
- ESP32-C6: Add timer wakeup source for deepsleep (#1201)
- Introduce `InterruptExecutor::spawner()` (#1211)
### Fixed

View File

@ -175,4 +175,19 @@ where
let executor = unsafe { (*self.executor.get()).assume_init_ref() };
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 started.
/// The function will panic otherwise.
pub fn spawner(&'static self) -> SendSpawner {
if self.core.load(Ordering::Acquire) == usize::MAX {
panic!("InterruptExecutor::spawner() called on uninitialized executor.");
}
let executor = unsafe { (&*self.executor.get()).assume_init_ref() };
executor.spawner().make_send()
}
}