Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
KillableExecutor, as its name suggests, is anarch-stdExecutorthat can be cleanly killed. The main noticeable difference is that theinitclosure passed torun()has a second parameter of typeKiller, which wraps aSignaler(so as to beCopyandClone). Thiskilleris checked during theExecutor's polling loop, and when signalled, causes theExecutorto exit.Rationale: Although it makes little sense to terminate a device-based Executor,
arch-stdis running on a conventional OS, and thus there are use-cases where it makes sense to terminate. Specifically, when testing 'embassy'-based code onstd-archwith h/w mocks, having a way to terminate theExecutorallows atest_harnessto be created such that#[test]andcargo testcan be used. Example:In the example, the #task-under-test#
clock_taskis first spawned, followed by a separate test taskclock_test_taskwhich receives the killer object and signals theExecutorto shut down once the tests have finished. In this way,cargo testcontinues and runs the next#[test].Example
test_harness:I'm pretty sure there's some cleanup missing .. and I'm not yet certain what happens if a test panics, but I'm submitting this initial PR as a way to solicit comments from the more knowledgeable, as to whether this is viable.