Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go1.23: 76-time-after no longer relevant #104

Open
jmcmullan opened this issue Oct 18, 2024 · 0 comments
Open

go1.23: 76-time-after no longer relevant #104

jmcmullan opened this issue Oct 18, 2024 · 0 comments
Labels
erratum Erratum

Comments

@jmcmullan
Copy link

As of Go 1.23, garbage collection of time.After() has improved, as per go1.23 doc time.After.

package time // import "time"

func After(d Duration) <-chan Time
    After waits for the duration to elapse and then sends the current time on
    the returned channel. It is equivalent to NewTimer(d).C.

    Before Go 1.23, this documentation warned that the underlying Timer
    would not be recovered by the garbage collector until the timer fired,
    and that if efficiency was a concern, code should use NewTimer instead and
    call Timer.Stop if the timer is no longer needed. As of Go 1.23, the garbage
    collector can recover unreferenced, unstopped timers. There is no reason to
    prefer NewTimer when After will do.
@jmcmullan jmcmullan added the erratum Erratum label Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
erratum Erratum
Projects
None yet
Development

No branches or pull requests

1 participant