Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
time: add (*Timer).Reset(d Duration) #4412
Some use cases for timers require extending the timer's deadline or resetting it to fire again. Implementing this using the existing time functions NewTimer and AfterFunc is somewhat awkward and error-prone. Instead, let's add: // Reset resets the time remaining on the timer to d. func (*Timer) Reset(d Duration)
I don't think we should make any guarantees about the channel contents, since this is racy. But perhaps Reset should expose the same information as Stop, that is, a boolean indicating whether the Reset happened before the timer fired. But I would omit even that bit for now, until there's a demonstrated need.