Hi,

I understand how it works and I confess this is very pedantic.
It's the word "single" in the sentence "Timer type represents a single 
event" in the description of the Timer type that I object to.
If event corresponds to either the function given to AfterFunc or sending 
the time of expiry to the channel in the case it was created using 
NewTimer, then the event can be emitted more than a single time.

Sorry for the noise on this extremely minor detail.

All the best,
Johan B

torsdag 6 juli 2023 kl. 02:10:05 UTC+2 skrev peterGo:

> Johan,
>
> For https://play.golang.com/p/Kdg-xwmquQO, timer has expired and Reset 
> schedules f to run again and returns false.
>
> Documentation reference: https://pkg.go.dev/time#Timer.Reset
>
> Reset changes the timer to expire after duration d. It returns true if the 
> timer had been active, false if the timer had expired or been stopped.
>
> For a Timer created with AfterFunc(d, f), Reset either reschedules when f 
> will run, in which case Reset returns true, or schedules f to run again, in 
> which case it returns false.
>
> Peter
>
> On Wednesday, July 5, 2023 at 5:33:46 PM UTC-4 Johan Bolmsjö wrote:
>
>> Hello,
>>
>> By accident I came across the statement "Timer type represents a single 
>> event" when seeking inspiration for a timer implementation.
>> I wonder if this is true with the Timer.Reset method in mind, illustrated 
>> by https://play.golang.com/p/Kdg-xwmquQO.
>>
>> This is probably the least important topic of the year but I hesitated 
>> creating a ticket for it as I'm not sure my idea of an event is what the 
>> comment refers to.
>>
>> Documentation reference: https://pkg.go.dev/time#Timer
>>
>> All the best,
>> Johan B
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/713dc762-fccd-455c-8abe-ac2c99e64771n%40googlegroups.com.

Reply via email to