mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-12-10 23:45:42 +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 {
|
func (p *Pacemaker) start() error {
|
||||||
tick := time.NewTicker(p.Heartrate)
|
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
|
// Echo at least once
|
||||||
p.Echo()
|
p.Echo()
|
||||||
|
|
Loading…
Reference in a new issue