@@ -54,8 +54,8 @@ type Timer struct {
54
54
// Stop does not close the channel, to prevent a read from the channel succeeding
55
55
// incorrectly.
56
56
//
57
- // To prevent a timer created with NewTimer from firing after a call to Stop,
58
- // check the return value and drain the channel.
57
+ // To ensure the channel is empty after a call to Stop, check the
58
+ // return value and drain the channel.
59
59
// For example, assuming the program has not received from t.C already:
60
60
//
61
61
// if !t.Stop() {
@@ -97,10 +97,9 @@ func NewTimer(d Duration) *Timer {
97
97
// It returns true if the timer had been active, false if the timer had
98
98
// expired or been stopped.
99
99
//
100
- // Resetting a timer must take care not to race with the send into t.C
101
- // that happens when the current timer expires.
100
+ // Reset should be invoked only on stopped or expired timers with drained channels.
102
101
// If a program has already received a value from t.C, the timer is known
103
- // to have expired, and t.Reset can be used directly.
102
+ // to have expired and the channel drained, so t.Reset can be used directly.
104
103
// If a program has not yet received a value from t.C, however,
105
104
// the timer must be stopped and—if Stop reports that the timer expired
106
105
// before being stopped—the channel explicitly drained:
0 commit comments