Merge pull request #4049 from kaspar030/executor_id

embassy-executor: introduce `Executor::id()`, `Spawner::executor_id()`
This commit is contained in:
Dario Nieuwenhuis 2025-04-06 21:55:04 +00:00 committed by GitHub
commit cee3b49344
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View File

@ -555,6 +555,11 @@ impl Executor {
pub fn spawner(&'static self) -> super::Spawner {
super::Spawner::new(self)
}
/// Get a unique ID for this Executor.
pub fn id(&'static self) -> usize {
&self.inner as *const SyncExecutor as usize
}
}
/// Wake a task by `TaskRef`.

View File

@ -173,6 +173,11 @@ impl Spawner {
pub fn make_send(&self) -> SendSpawner {
SendSpawner::new(&self.executor.inner)
}
/// Return the unique ID of this Spawner's Executor.
pub fn executor_id(&self) -> usize {
self.executor.id()
}
}
/// Handle to spawn tasks into an executor from any thread.