diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-12-12 15:38:56 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-12-12 15:38:56 +0000 |
| commit | 640ca72c0e33b252026191ac9bc64fa6b0c9b166 (patch) | |
| tree | ea6be7b3f900a4dc44b1c1a4ac104e4154cd3ec5 /embassy-executor | |
| parent | 778bd76c1c2746ac9564132bcab0f8359feb7b13 (diff) | |
| parent | b1fe9c6955ff857e3729a0bb4727247e050fb7ae (diff) | |
Merge pull request #5047 from Gerharddc/executor-cancel
Add `run_until` function to std Executor as to support grafeul shutdown.
Diffstat (limited to 'embassy-executor')
| -rw-r--r-- | embassy-executor/CHANGELOG.md | 1 | ||||
| -rw-r--r-- | embassy-executor/src/arch/std.rs | 15 |
2 files changed, 15 insertions, 1 deletions
diff --git a/embassy-executor/CHANGELOG.md b/embassy-executor/CHANGELOG.md index 5fbb8cf13..8f1db7de7 100644 --- a/embassy-executor/CHANGELOG.md +++ b/embassy-executor/CHANGELOG.md | |||
| @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
| 15 | - Added optional "earliest deadline first" EDF scheduling | 15 | - Added optional "earliest deadline first" EDF scheduling |
| 16 | - Migrate `cortex-ar` to `aarch32-cpu`. The feature name `arch-cortex-ar` remains the same and | 16 | - Migrate `cortex-ar` to `aarch32-cpu`. The feature name `arch-cortex-ar` remains the same and |
| 17 | legacy ARM architectures are not supported. | 17 | legacy ARM architectures are not supported. |
| 18 | - Added `run_until` to `arch-std` variant of `Executor`. | ||
| 18 | 19 | ||
| 19 | ## 0.9.1 - 2025-08-31 | 20 | ## 0.9.1 - 2025-08-31 |
| 20 | 21 | ||
diff --git a/embassy-executor/src/arch/std.rs b/embassy-executor/src/arch/std.rs index c62ab723b..d4057144e 100644 --- a/embassy-executor/src/arch/std.rs +++ b/embassy-executor/src/arch/std.rs | |||
| @@ -55,11 +55,24 @@ mod thread { | |||
| 55 | /// | 55 | /// |
| 56 | /// This function never returns. | 56 | /// This function never returns. |
| 57 | pub fn run(&'static mut self, init: impl FnOnce(Spawner)) -> ! { | 57 | pub fn run(&'static mut self, init: impl FnOnce(Spawner)) -> ! { |
| 58 | self.run_until(init, || false); | ||
| 59 | unreachable!() | ||
| 60 | } | ||
| 61 | |||
| 62 | /// Run the executor until a flag is raised. | ||
| 63 | /// | ||
| 64 | /// This function is identical to `Executor::run()` apart from offering a `done` flag to stop execution. | ||
| 65 | pub fn run_until(&'static mut self, init: impl FnOnce(Spawner), mut done: impl FnMut() -> bool) { | ||
| 58 | init(self.inner.spawner()); | 66 | init(self.inner.spawner()); |
| 59 | 67 | ||
| 60 | loop { | 68 | loop { |
| 61 | unsafe { self.inner.poll() }; | 69 | unsafe { self.inner.poll() }; |
| 62 | self.signaler.wait() | 70 | |
| 71 | if done() { | ||
| 72 | break; | ||
| 73 | } | ||
| 74 | |||
| 75 | self.signaler.wait(); | ||
| 63 | } | 76 | } |
| 64 | } | 77 | } |
| 65 | } | 78 | } |
