Skip to content

refactor: don't block if timer runs out (behaviour change from Go 1.23)#1179

Merged
a-h merged 1 commit intoa-h:mainfrom
philip-peterson:no-block
Jun 5, 2025
Merged

refactor: don't block if timer runs out (behaviour change from Go 1.23)#1179
a-h merged 1 commit intoa-h:mainfrom
philip-peterson:no-block

Conversation

@philip-peterson
Copy link
Copy Markdown
Contributor

The go documentation states:

For a chan-based timer created with NewTimer(d), as of Go 1.23, any receive from t.C after Stop has returned is guaranteed to block rather than receive a stale time value from before the Stop; if the program has not received from t.C already and the timer is running, Stop is guaranteed to return true. Before Go 1.23, the only safe way to use Stop was insert an extra <-t.C if Stop returned false to drain a potential stale value.

https://pkg.go.dev/time#Timer.Stop

@a-h a-h changed the title Do not block if timer has run out refactor: don't block if timer runs out (behaviour change from Go 1.23) Jun 5, 2025
@a-h a-h merged commit 780cab0 into a-h:main Jun 5, 2025
5 checks passed
@philip-peterson philip-peterson deleted the no-block branch June 6, 2025 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants