Files
mautrix-telegram/pkg/gotd/clock/clock.go
T
2025-06-27 20:03:37 -07:00

32 lines
568 B
Go

// Package clock abstracts time source.
package clock
import (
"time"
"github.com/gotd/neo"
)
// Clock is current time source.
type Clock interface {
Now() time.Time
Timer(d time.Duration) Timer
Ticker(d time.Duration) Ticker
}
// Timer abstracts a single event.
type Timer = neo.Timer
// StopTimer stops timer and drains timer channel if Stop() returned false.
func StopTimer(t Timer) {
if !t.Stop() {
select {
case <-t.C():
default:
}
}
}
// Ticker abstracts a channel that delivers “ticks” of a clock at intervals.
type Ticker = neo.Ticker