@@ -2,6 +2,9 @@ package clock
2
2
3
3
import "time"
4
4
5
+ // The Timer type represents a single event. When the Timer expires, the current time will be sent
6
+ // on C, unless the Timer was created by AfterFunc. A Timer must be created with NewTimer or
7
+ // AfterFunc.
5
8
type Timer struct {
6
9
C <- chan time.Time
7
10
//nolint: revive
@@ -26,6 +29,11 @@ func (t *Timer) next() time.Time {
26
29
return t .nxt
27
30
}
28
31
32
+ // Stop prevents the Timer from firing. It returns true if the call stops the timer, false if the
33
+ // timer has already expired or been stopped. Stop does not close the channel, to prevent a read
34
+ // from the channel succeeding incorrectly.
35
+ //
36
+ // See https://pkg.go.dev/time#Timer.Stop for more information.
29
37
func (t * Timer )Stop (tags ... string )bool {
30
38
if t .timer != nil {
31
39
return t .timer .Stop ()
@@ -40,6 +48,10 @@ func (t *Timer) Stop(tags ...string) bool {
40
48
return result
41
49
}
42
50
51
+ // Reset changes the timer to expire after duration d. It returns true if the timer had been active,
52
+ // false if the timer had expired or been stopped.
53
+ //
54
+ // See https://pkg.go.dev/time#Timer.Reset for more information.
43
55
func (t * Timer )Reset (d time.Duration ,tags ... string )bool {
44
56
if t .timer != nil {
45
57
return t .timer .Reset (d )