mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-12-02 20:02:53 +00:00
Gateway: Fixed unexpected ticker.Stop() blocking behavior
This commit is contained in:
parent
01e52334c6
commit
320e8a52f1
|
@ -69,7 +69,19 @@ func (p *Pacemaker) Stop() {
|
|||
|
||||
func (p *Pacemaker) start() error {
|
||||
tick := time.NewTicker(p.Heartrate)
|
||||
defer tick.Stop()
|
||||
|
||||
defer func() {
|
||||
// Flush the ticker:
|
||||
select {
|
||||
case <-tick.C:
|
||||
WSDebug("Flushed a tick.")
|
||||
default:
|
||||
WSDebug("No tick flushed.")
|
||||
}
|
||||
|
||||
// Then close the ticker:
|
||||
tick.Stop()
|
||||
}()
|
||||
|
||||
// Echo at least once
|
||||
p.Echo()
|
||||
|
|
Loading…
Reference in a new issue