mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-02-27 01:07:10 +00:00
chore: better timer using
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user