tstime: add Since method (#8622)

Updates #8463

Signed-off-by: Claire Wang <claire@tailscale.com>
This commit is contained in:
Claire Wang
2023-07-14 16:50:17 -04:00
committed by GitHub
parent 60e5761d60
commit 0573f6e953
3 changed files with 57 additions and 0 deletions

View File

@ -303,6 +303,11 @@ func (c *Clock) AfterFunc(d time.Duration, f func()) tstime.TimerController {
return t
}
// Since subtracts specified duration from Now().
func (c *Clock) Since(t time.Time) time.Duration {
return c.Now().Sub(t)
}
// eventHandler offers a common interface for Timer and Ticker events to avoid
// code duplication in eventManager.
type eventHandler interface {