timer.go 515 B

1234567891011121314151617181920
  1. // Copyright 2024 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package http2
  5. import "time"
  6. // A timer is a time.Timer, as an interface which can be replaced in tests.
  7. type timer = interface {
  8. C() <-chan time.Time
  9. Reset(d time.Duration) bool
  10. Stop() bool
  11. }
  12. // timeTimer adapts a time.Timer to the timer interface.
  13. type timeTimer struct {
  14. *time.Timer
  15. }
  16. func (t timeTimer) C() <-chan time.Time { return t.Timer.C }