Groups | Search | Server Info | Login | Register
| From | John <john@building-m.simplistic-anti-spam-measure.net> |
|---|---|
| Newsgroups | comp.lang.go |
| Subject | Re: buffered channel |
| Date | 2024-04-14 17:56 +0000 |
| Organization | Building M |
| Message-ID | <868r1f25gr.fsf@building-m.net> (permalink) |
| References | <of1l1jpps6ckrs5ssuuskpts76rk1mnhue@4ax.com> |
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
Back to comp.lang.go | Previous | Next — Previous in thread | Next in thread | Find similar
buffered channel Rob <usenet@drrob1.com> - 2024-04-13 09:19 -0400
Re: buffered channel John <john@building-m.simplistic-anti-spam-measure.net> - 2024-04-14 17:56 +0000
Re: buffered channel a cat <a_cat@example.com> - 2024-04-16 09:58 -0600
csiph-web