Skip to content

Conversation

@AsakuraMizu
Copy link
Collaborator

Background

I borrowed the implementation of compio's TimerRuntime in one of my projects. It has now been suggested that this implementation could be simplified (Starry-OS/arceos#20). Since I wasn't sure, I moved his simplified implementation back to compio so that the original author could take a look at it to see if there were any problems.

Related commits:

@George-Miao George-Miao added refactor Refactoring existing code package: runtime Related to compio-runtime labels Nov 28, 2025
Copy link
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 simplifies the TimerRuntime implementation by removing the FutureState enum and directly storing Waker instances in the timer wheel. The refactoring reduces complexity while maintaining the same functionality.

Key changes:

  • Removed FutureState enum wrapper, storing Waker directly in BTreeMap<TimerKey, Waker>
  • Changed remove_completed() to is_completed() with simpler semantics (checking absence from map)
  • Refactored wake() method to use split_off() for efficient separation of expired vs pending timers

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
compio-runtime/src/runtime/time.rs Removed FutureState enum, simplified TimerRuntime to store wakers directly, refactored wake() using split_off(), reordered struct field initialization to match declaration order
compio-runtime/src/runtime/mod.rs Updated poll_timer to use renamed is_completed() method

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@AsakuraMizu AsakuraMizu marked this pull request as ready for review November 28, 2025 19:13
@AsakuraMizu AsakuraMizu changed the title [Experiment] simplify TimerRuntime refactor: simplify TimerRuntime Nov 28, 2025
Co-authored-by: mivik <mivikq@gmail.com>
@AsakuraMizu AsakuraMizu changed the title refactor: simplify TimerRuntime refactor(runtime): simplify TimerRuntime Nov 28, 2025
@George-Miao George-Miao merged commit 341ce94 into compio-rs:master Nov 29, 2025
94 of 95 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: runtime Related to compio-runtime refactor Refactoring existing code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants