mirror of
https://github.com/luxfi/timer.git
synced 2026-10-30 15:15:40 +00:00
- Remove meter.go (duplicate Meter interface) - Keep concrete Meter struct in clock.go - Add new timer files (adaptive, staged, stopped)
24 lines
611 B
Go
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
|
|
}
|