NewPool returns a Pool(), it's backed by a sync.Pool so its safe for concurrent use. Get() and Put() errors will always be nil. It will not work with gob.
(New func() Buffer)
| 24 | // Get() and Put() errors will always be nil. |
| 25 | // It will not work with gob. |
| 26 | func NewPool(New func() Buffer) Pool { |
| 27 | return &pool{ |
| 28 | pool: sync.Pool{ |
| 29 | New: func() interface{} { |
| 30 | return New() |
| 31 | }, |
| 32 | }, |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | func (p *pool) Get() (Buffer, error) { |
| 37 | return p.pool.Get().(Buffer), nil |
searching dependent graphs…