MCPcopy Create free account
hub / github.com/djherbis/buffer / NewPool

Function NewPool

pool.go:26–34  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

24// Get() and Put() errors will always be nil.
25// It will not work with gob.
26func NewPool(New func() Buffer) Pool {
27 return &pool{
28 pool: sync.Pool{
29 New: func() interface{} {
30 return New()
31 },
32 },
33 }
34}
35
36func (p *pool) Get() (Buffer, error) {
37 return p.pool.Get().(Buffer), nil

Callers 4

NewMemPoolFunction · 0.85
UnmarshalBinaryMethod · 0.85
TestPoolFunction · 0.85
TestBadPartitionFunction · 0.85

Calls 1

NewFunction · 0.85

Tested by 2

TestPoolFunction · 0.68
TestBadPartitionFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…