Skip to content

Timer::reset can't soundly have an optimized implementation #3027

Closed
@sfackler

Description

@sfackler

In 1.0.0-rc.1, the new Timer trait has a method to reset an existing Sleep to a new deadline. The default implementation simply creates a new Sleep and writes it over the old one, but presumably this method exists to it can be overridden with a better implementation when working with a timer like Tokio's that can have its deadline dynamically adjusted.

However, since the Sleep is provided as a dyn Sleep and Sleep has no downcasting APIs, there is no safe way to confirm that the Sleep instance is one created by this Timer implementation. That effectively means that the current default implementation is the only sound way of implementing the method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rtArea: runtime traits/utilsC-performanceCategory: performance. This is making existing behavior go faster.E-easyEffort: easy. A task that would be a great starting point for a new contributor.

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions