Forwarding to the mailing list this time.

Cheers.

On Dec 14, 2017 18:14, "Ivan Borshukov" <bo0mer...@gmail.com> wrote:

Ok, thanks.

If so, I want to announce the change that I've maid. It is regarding the
rate limiting section [0].

The wiki page states that when the created ticker is Stop-ed, the created
goroutine will exit,
which I think is not true, since the Ticker.Stop's documentation[1] states
that Stop does not
result in Ticker.C being closed. A minimal example confirms my
understanding and results
in a panic due to deadlock.

```go
package main

import (
"sync"
"time"
)

func main() {
tick := time.NewTicker(time.Second)
throttle := make(chan time.Time, 1)

wg := sync.WaitGroup{}
wg.Add(1)
go func() {
defer wg.Done()
for t := range tick.C {
select {
case throttle <- t:
default:
}
} // Wiki page says: exits after tick.Stop()
}()

tick.Stop()
wg.Wait()
}
```

The above code in the playground: https://play.golang.org/p/oWrcCa25ki.

The diff can be viewed at [2].


[0] https://github.com/golang/go/wiki/RateLimiting
[1] https://godoc.org/time#Ticker.Stop
[2] https://github.com/golang/go/wiki/RateLimiting/_compare/
1a0ca7c57e7845c9ff05d296b721b46afa7c4f9e...67bbbe92527c42753
b45775ac981e14d89b2b95e

Cheers,
Ivan

2017-12-14 18:06 GMT+02:00 Jan Mercl <0xj...@gmail.com>:

> On Thu, Dec 14, 2017 at 5:05 PM Ivan Borshukov <bo0mer...@gmail.com>
> wrote:
>
> > I've noticed that I'm able to edit the wiki pages on
> https://github.com/golang/go/wiki and I wonder whether this is
> intentional.
>
> IINM, it's like that from the beginning of the Github repository, so
> probably intentional.
>
> --
>
> -j
>



-- 
Ivan Borshukov, bo0mer...@gmail.com

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to