Re: [go-nuts] Re: Fixed channel capacity in NotifyContext function in os/signals package

2021-07-05 Thread Erman İmer
Awesome, thanks! On Mon, Jul 5, 2021 at 2:11 PM Axel Wagner wrote: > FWIW writing to a channel non-blockingly works like this: > > select { > case ch <- v: > default: > } > > If no communication can proceed (i.e. the write would block) the default > case is chosen. > > On Mon, Jul 5, 2021 at 1:0

Re: [go-nuts] Re: Fixed channel capacity in NotifyContext function in os/signals package

2021-07-05 Thread 'Axel Wagner' via golang-nuts
FWIW writing to a channel non-blockingly works like this: select { case ch <- v: default: } If no communication can proceed (i.e. the write would block) the default case is chosen. On Mon, Jul 5, 2021 at 1:09 PM Erman İmer wrote: > Thank you! I was confused about the highlighted part "For a ch

Re: [go-nuts] Re: Fixed channel capacity in NotifyContext function in os/signals package

2021-07-05 Thread Erman İmer
Thank you! I was confused about the highlighted part "For a channel used for notification of *just one* signal value, a buffer of size 1 is sufficient.*" *But I am convinced after realizing the single read on the 289th line. I will also spend some time understanding how Notify writes signals non-bl

Re: [go-nuts] Re: Fixed channel capacity in NotifyContext function in os/signals package

2021-07-05 Thread 'Axel Wagner' via golang-nuts
The documentation is actually very specific here: Package signal will not block sending to c: the caller must ensure that c > has sufficient buffer space to keep up with the expected signal rate. *For > a channel used for notification of just one signal v

Re: [go-nuts] Re: Fixed channel capacity in NotifyContext function in os/signals package

2021-07-05 Thread 'Axel Wagner' via golang-nuts
On Mon, Jul 5, 2021 at 12:41 PM Erman İmer wrote: > I think it is not about the context's cancellation. The signal channel > should have a sufficient buffer size. > 1 is a sufficient buffer size. Note that there is *exactly one* read from c.ch in https://github.com/golang/go/blob/912f0750472dd4f

Re: [go-nuts] Re: Fixed channel capacity in NotifyContext function in os/signals package

2021-07-05 Thread Erman İmer
Another former discussion: https://github.com/golang/lint/issues/175 On Mon, Jul 5, 2021 at 1:41 PM Erman İmer wrote: > I think it is not about the context's cancellation. The signal channel > should have a sufficient buffer size. > > Please check the former discussion which determined the Notif

Re: [go-nuts] Re: Fixed channel capacity in NotifyContext function in os/signals package

2021-07-05 Thread Erman İmer
I think it is not about the context's cancellation. The signal channel should have a sufficient buffer size. Please check the former discussion which determined the Notify function's description. https://github.com/dominikh/go-staticcheck/issues/30 Best regards On Mon, Jul 5, 2021 at 1:28 PM Sea

[go-nuts] Re: Fixed channel capacity in NotifyContext function in os/signals package

2021-07-05 Thread Sean Liao
What problem are you trying to solve? It only makes sense for NotifyContext to receive a single signal since a context can only be cancelled once On Monday, July 5, 2021 at 10:17:49 AM UTC+2 erma...@gmail.com wrote: > Sorry about the broken link, here is the line: > > https://github.com/golang/g

[go-nuts] Re: Fixed channel capacity in NotifyContext function in os/signals package

2021-07-05 Thread erma...@gmail.com
Sorry about the broken link, here is the line: https://github.com/golang/go/blob/912f0750472dd4f674b69ca1616bfaf377af1805/src/os/signal/signal.go#L284 On Monday, July 5, 2021 at 11:15:11 AM UTC+3 erma...@gmail.com wrote: > Hello, > > I have an improvement idea for the following line in the os/sig