Files
timer/staged_timer.go
zeekay 257fab9d01 refactor: consolidate Meter type, remove duplicate interface
- Remove meter.go (duplicate Meter interface)
- Keep concrete Meter struct in clock.go
- Add new timer files (adaptive, staged, stopped)
2026-01-09 14:50:46 -08:00

24 lines
611 B
Go

// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package timer
import "time"
// NewStagedTimer returns a timer that will execute [f]
// when a timeout occurs and execute an additional timeout after
// the returned duration if [f] returns true and some duration.
//
// Deprecated: NewStagedTimer exists for historical compatibility
// and should not be used.
func NewStagedTimer(f func() (time.Duration, bool)) *Timer {
t := NewTimer(nil)
t.handler = func() {
delay, repeat := f()
if repeat {
t.SetTimeoutIn(delay)
}
}
return t
}