-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
good first issueGood for newcomersGood for newcomers
Description
Problem
After a discussion with @kompiangg, it seems we're better-off to use time.Ticker instead of time.Sleep. This is for these reasons:
- Much more appropriate in an interval-based recurring loop.
- It uses channel, allows us to enable things like context cancellation called from another goroutine.
This has in theory nothing to do with performance, just for convenient on handling the context cancellation in the future.
Both time.Sleep and time.Ticker only suspends the goroutine (green threads). The Go scheduler removes it from the Run queue to prevent the consumption of CPU resources.
The OS Thread meanwhile isn't blocked by the suspended goroutine as the Go scheduler will reassign the OS Thread to another goroutine. Sort of a context-switching at the green-thread level.
Reference:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomers