FAQ
Hello,

I am wondering what the use cases of a sync.Pool
<http://godoc.org/sync#Pool> could be in comparison to a buffered channel?

The docs say that sync.Pool is used to "cache" output to stdio. I guess
that a sync.Pool may benefit here as it does not have a limit in size.

I still see two downsides on using sync.Pool over buffered channel:
1. Limiting the size via buffered channels may prevent memory problems
2. Using select or for over a channel uses less resources then always
checking pool.Get() for non-nil values

On the other side I am sure the Go devs would not have added sync.Pool if
there would be no reason. So what am I missing?

Best,
Bo

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 4 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 4, '14 at 9:58a
activeSep 4, '14 at 11:29a
posts4
users2
websitegolang.org

2 users in discussion

Dmitry Vyukov: 3 posts I: 1 post

People

Translate

site design / logo © 2021 Grokbase