fix(runtime): store active task's Waker in Scheduler#494
Merged
Conversation
ed69c39 to
7ebe828
Compare
George-Miao
reviewed
Oct 27, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where futures could be dropped on the wrong thread by storing active task Wakers in the Scheduler and ensuring all futures are dropped within the runtime context. The implementation is inspired by async-executor::LocalExecutor.
Key changes:
- Added
active_tasksfield toSchedulerto track all active task wakers - Introduced
DropHookwrapper to execute cleanup when futures are dropped - Implemented
clear()method to properly clean up all tasks before scheduler destruction
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| compio-runtime/tests/drop.rs | Added test case to verify futures are properly dropped within runtime context |
| compio-runtime/src/runtime/scheduler/mod.rs | Added waker storage and clear mechanism to ensure thread-safe task cleanup |
| compio-runtime/src/runtime/scheduler/drop_hook.rs | New utility to run cleanup hooks when futures are dropped |
| compio-runtime/src/runtime/mod.rs | Implemented Drop for Runtime to clear scheduler tasks on destruction |
| compio-runtime/Cargo.toml | Made slab a required dependency and added pin-project-lite |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Berrysoft
requested changes
Oct 27, 2025
0eacc8a to
fbda149
Compare
fbda149 to
4040b61
Compare
Berrysoft
approved these changes
Oct 27, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixed the issue where a future could be dropped on another thread, and ensured that futures are always dropped within the runtime context, because dropping a future may require access to the context.
Inspired by the implementation of
async-executor::LocalExecutor.Supersedes #493