Skip to content

fix(runtime): store active task's Waker in Scheduler#494

Merged
Berrysoft merged 1 commit into
compio-rs:masterfrom
Paraworker:fix/store-waker
Oct 27, 2025
Merged

fix(runtime): store active task's Waker in Scheduler#494
Berrysoft merged 1 commit into
compio-rs:masterfrom
Paraworker:fix/store-waker

Conversation

@Paraworker
Copy link
Copy Markdown
Contributor

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

Comment thread compio-runtime/src/runtime/scheduler/drop_hook.rs
@George-Miao George-Miao added bug Something isn't working package: runtime Related to compio-runtime labels Oct 27, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_tasks field to Scheduler to track all active task wakers
  • Introduced DropHook wrapper 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.

Comment thread compio-runtime/src/runtime/scheduler/drop_hook.rs
Comment thread compio-runtime/tests/drop.rs Outdated
Comment thread compio-runtime/src/runtime/scheduler/mod.rs
Comment thread compio-runtime/Cargo.toml Outdated
Comment thread compio-runtime/src/runtime/scheduler/mod.rs
Copy link
Copy Markdown
Member

@George-Miao George-Miao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Berrysoft Berrysoft merged commit c3eb5f7 into compio-rs:master Oct 27, 2025
49 checks passed
@Paraworker Paraworker deleted the fix/store-waker branch October 27, 2025 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working package: runtime Related to compio-runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants