Skip to content

time: Timer.Reset documentation not accurate for AfterFunc timers #28100

@bradfitz

Description

@bradfitz

https://golang.org/pkg/time/#Timer.Reset says:

Resetting a timer must take care not to race with the send into t.C that happens when the current timer expires. If a program has already received a value from t.C, the timer is known to have expired, and t.Reset can be used directly. If a program has not yet received a value from t.C, however, the timer must be stopped and—if Stop reports that the timer expired before being stopped—the channel explicitly drained:

And proceeds to give an example of proper usage of Reset.

But a Timer created by AfterFunc never sends on the channel.

We should probably say something about AfterFunc in the Timer.Reset docs.

/cc @dmitshur @ianlancetaylor

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.help wanted

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions