Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

Fascinating, a totally parochial attitude. -- Spock, "Metamorphosis", stardate 3219.8


devel / comp.lang.go / Re: buffered channel

SubjectAuthor
* buffered channelRob
`* Re: buffered channelJohn
 `- Re: buffered channela cat

1
buffered channel

<of1l1jpps6ckrs5ssuuskpts76rk1mnhue@4ax.com>

  copy mid

http://rslight.i2p/devel/article-flat.php?id=31&group=comp.lang.go#31

  copy link   Newsgroups: comp.lang.go
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: usenet@drrob1.com (Rob)
Newsgroups: comp.lang.go
Subject: buffered channel
Date: Sat, 13 Apr 2024 09:19:13 -0400
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <of1l1jpps6ckrs5ssuuskpts76rk1mnhue@4ax.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 13 Apr 2024 15:19:15 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="d6c6f485e84bde4ce9717b939e3fd151";
logging-data="3181720"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19T/tLCteuOOzNCxjjylVgR35lBF8+ApXg="
User-Agent: ForteAgent/8.00.32.1272
Cancel-Lock: sha1:/9osaIYkoaAg1HXorCW3ma8+Mls=
 by: Rob - Sat, 13 Apr 2024 13:19 UTC

I'm looking to better understand buffered channels.

I understand that using a buffer of 1 prevents certain kinds of
goroutine leaks

Are their any guidelines or caviats on how big to make the buffer size
for a channel?

Thanks
Rob

Re: buffered channel

<868r1f25gr.fsf@building-m.net>

  copy mid

http://rslight.i2p/devel/article-flat.php?id=32&group=comp.lang.go#32

  copy link   Newsgroups: comp.lang.go
Path: i2pn2.org!i2pn.org!news.quux.org!news.building-m.net!.POSTED.localhost!not-for-mail
From: john@building-m.simplistic-anti-spam-measure.net (John)
Newsgroups: comp.lang.go
Subject: Re: buffered channel
Date: Sun, 14 Apr 2024 17:56:36 +0000
Organization: Building M
Message-ID: <868r1f25gr.fsf@building-m.net>
References: <of1l1jpps6ckrs5ssuuskpts76rk1mnhue@4ax.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: ritvax.building-m.net; posting-host="localhost:::1";
logging-data="2759281"; mail-complaints-to="abuse@building-m.net"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:FQjeKPAvfr5pZtP8L6Rqe+dvpcg=
 by: John - Sun, 14 Apr 2024 17:56 UTC

Rob <usenet@drrob1.com> writes:

> I'm looking to better understand buffered channels.
>
> I understand that using a buffer of 1 prevents certain kinds of
> goroutine leaks
>
> Are their any guidelines or caviats on how big to make the buffer size
> for a channel?
>
> Thanks
> Rob

It's not a magic bullet to prevent goroutine leaks... I guess the
advantage of setting the size to 1 means that the writing goroutine will
be able to write and exit, even if you forget to read the channel
elsewhere.

If your code falls over with a buffer size of 10, it'll probably fall
over (but slower) with a buffer size of 1000 -- that, or it'll
"complete" but still be wrong.

john

Re: buffered channel

<uvm76b$10vmp$1@dont-email.me>

  copy mid

http://rslight.i2p/devel/article-flat.php?id=33&group=comp.lang.go#33

  copy link   Newsgroups: comp.lang.go
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: a_cat@example.com (a cat)
Newsgroups: comp.lang.go
Subject: Re: buffered channel
Date: Tue, 16 Apr 2024 09:58:03 -0600
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <uvm76b$10vmp$1@dont-email.me>
References: <of1l1jpps6ckrs5ssuuskpts76rk1mnhue@4ax.com>
<868r1f25gr.fsf@building-m.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 16 Apr 2024 17:58:03 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="655c3c72e12b6d5587fc447ccc90f03b";
logging-data="1081049"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19T9hMElrLHtQ1kzk9siTXX"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:kAyYug36/2IVjqyZqHRTyXVhDLg=
In-Reply-To: <868r1f25gr.fsf@building-m.net>
Content-Language: en-US
 by: a cat - Tue, 16 Apr 2024 15:58 UTC

On 4/14/24 11:56, John wrote:
> Rob <usenet@drrob1.com> writes:
>
>> I'm looking to better understand buffered channels.
>>
>> I understand that using a buffer of 1 prevents certain kinds of
>> goroutine leaks
>>
>> Are their any guidelines or caviats on how big to make the buffer size
>> for a channel?
>>
>> Thanks
>> Rob
>
> It's not a magic bullet to prevent goroutine leaks... I guess the
> advantage of setting the size to 1 means that the writing goroutine will
> be able to write and exit, even if you forget to read the channel
> elsewhere.
>
> If your code falls over with a buffer size of 10, it'll probably fall
> over (but slower) with a buffer size of 1000 -- that, or it'll
> "complete" but still be wrong.
>
> john

I agree. I would start out using unbuffered channels until you know that
you need a buffered one, and why. Buffered channels can hide bugs.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor