File: pool.go

package info (click to toggle)
golang-github-gobwas-pool 0.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 116 kB
  • sloc: makefile: 2
file content (25 lines) | stat: -rw-r--r-- 663 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Package pool contains helpers for pooling structures distinguishable by
// size.
//
// Quick example:
//
//   import "github.com/gobwas/pool"
//
//   func main() {
//      // Reuse objects in logarithmic range from 0 to 64 (0,1,2,4,6,8,16,32,64).
//      p := pool.New(0, 64)
//
//      buf, n := p.Get(10) // Returns buffer with 16 capacity.
//      if buf == nil {
//          buf = bytes.NewBuffer(make([]byte, n))
//      }
//      defer p.Put(buf, n)
//
//      // Work with buf.
//   }
//
// There are non-generic implementations for pooling:
// - pool/pbytes for []byte reuse;
// - pool/pbufio for *bufio.Reader and *bufio.Writer reuse;
//
package pool