Between those two lines (fetching value from channel and sending it back to
channel) channel is empty.
This leads to two possible errors:
- less dangerous is if some checks channel in non-blocking mode (ie select
with default). Then it sees empty channel and thinks value is not set yet.
- more dan
On 18 October 2017 at 06:05, Sokolov Yura wrote:
> Following is a dangerous error-prone technique. If you use it in you program,
> most likely you have a hidden bug, that will appear in high concurrency
> situation.
>
> ```
> func wait(c chan T) T {
> v := <-c
> c <- v;
>
Following is a dangerous error-prone technique. If you use it in you program,
most likely you have a hidden bug, that will appear in high concurrency
situation.
```
func wait(c chan T) T {
v := <-c
c <- v;
return v;
}
```
I had proposal for future primitive: http
If you have serious performance needs, then something like the "Disruptor"
pattern is useful. There are ports of that from Java to Go out there, but I
don't know how stable or useful they are.
The Disruptor pattern is to keep a circular ring-buffer of elements. The
writer and each reader keeps tra
that's an great article thank you!
On Sunday, October 15, 2017 at 6:51:03 PM UTC-7, dja...@gmail.com wrote:
>
> This post might help:
>
> https://rogpeppe.wordpress.com/2009/12/01/concurrent-idioms-1-broadcasting-values-in-go-with-linked-channels/
>
> Djadala
>
> On Sunday, October 15, 2017 at 11
https://golang.org/pkg/io/#TeeReader
should help you out
best,
Rene
Am Sonntag, 15. Oktober 2017 22:36:36 UTC+2 schrieb st ov:
>
> A value sent through a channel can be read by only one reader, so once its
> read its no longer available to other readers is that right?
>
> In what ways can I pa
My feeling is that a variable paired with a sync.Cond might be the right
choice if you are broadcasting a single value change.
I can't think of an readily available lib / language feature to support
broadcasting multiple value change though.
On Monday, 16 October 2017 06:36:36 UTC+10, st ov wro
And here is some working code:
https://play.golang.org/p/1Qt-LqKiph
Djadala
On Sunday, October 15, 2017 at 11:36:36 PM UTC+3, st ov wrote:
>
> A value sent through a channel can be read by only one reader, so once its
> read its no longer available to other readers is that right?
>
> In what way
This post might help:
https://rogpeppe.wordpress.com/2009/12/01/concurrent-idioms-1-broadcasting-values-in-go-with-linked-channels/
Djadala
On Sunday, October 15, 2017 at 11:36:36 PM UTC+3, st ov wrote:
>
> A value sent through a channel can be read by only one reader, so once its
> read its no