mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-01-04 00:23:43 +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) {
|
func (s *SlowDown) Wait(ctx context.Context) (err error) {
|
||||||
|
timer := time.NewTimer(s.backoff.Duration())
|
||||||
|
defer timer.Stop()
|
||||||
select {
|
select {
|
||||||
case <-time.After(s.backoff.Duration()):
|
case <-timer.C:
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
err = ctx.Err()
|
err = ctx.Err()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user