mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-12-22 23:57:26 +08:00
chore: better timer using
This commit is contained in:
parent
985b884d85
commit
23e3f12e88
@ -12,8 +12,10 @@ type SlowDown struct {
|
||||
}
|
||||
|
||||
func (s *SlowDown) Wait(ctx context.Context) (err error) {
|
||||
timer := time.NewTimer(s.backoff.Duration())
|
||||
defer timer.Stop()
|
||||
select {
|
||||
case <-time.After(s.backoff.Duration()):
|
||||
case <-timer.C:
|
||||
case <-ctx.Done():
|
||||
err = ctx.Err()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user