On Thu, Nov 12, 2020 at 11:13 PM 陶青云 <qingyu...@gmail.com> wrote:
>
>
> It is not a one-length buffered channel.  I need to drop because the 
> recveiver do heavy work that can't process as quickly as sender.

Don't use channels for this.  It's not what they are for.

Ian



> 在2020年11月13日星期五 UTC+8 下午2:36:13<Kurtis Rader> 写道:
>>
>> On Thu, Nov 12, 2020 at 9:32 PM 陶青云 <qing...@gmail.com> wrote:
>>>
>>> Thanks. I want the receiver always get the relately new vaule,  I don't 
>>> want the sender blocked and I either choose drop the current value or the 
>>> first value of the channel. But I don't find a way to safely drop the first 
>>> value from the channel.
>>
>>
>> You seem to be talking about a buffered channel of length one. If that is 
>> true why are you using a channel? You can instead use a simple var protected 
>> by a mutex. If you're talking about a buffered channel with size greater 
>> than one it is unclear why a full channel should drop the first entry in the 
>> channel rather than multiple (even all) entries in the queue. This seems 
>> like an XY problem.
>>
>>>
>>> Maybe like this ?
>>
>>
>> No, since that "solution" just replaces one race with another.
>>
>> --
>> Kurtis Rader
>> Caretaker of the exceptional canines Junior and Hank
>
> --
> 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/5f5cb0c2-54e9-4d5f-bbc7-43c902615b8fn%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcUjEPj3%2BWFpnBsgiPvKMZqbpNn%3DM1-eN6m6B4bXtvRp7A%40mail.gmail.com.

Reply via email to