Last change
on this file since 822 was 822, checked in by yakumo.izuru, 22 months ago |
Prefer immortal.run over runit and rc.d, use vendored modules
for convenience.
Signed-off-by: Izuru Yakumo <yakumo.izuru@…>
|
File size:
360 bytes
|
Line | |
---|
1 | package bpool
|
---|
2 |
|
---|
3 | import (
|
---|
4 | "bytes"
|
---|
5 | "sync"
|
---|
6 | )
|
---|
7 |
|
---|
8 | var bpool sync.Pool
|
---|
9 |
|
---|
10 | // Get returns a buffer from the pool or creates a new one if
|
---|
11 | // the pool is empty.
|
---|
12 | func Get() *bytes.Buffer {
|
---|
13 | b := bpool.Get()
|
---|
14 | if b == nil {
|
---|
15 | return &bytes.Buffer{}
|
---|
16 | }
|
---|
17 | return b.(*bytes.Buffer)
|
---|
18 | }
|
---|
19 |
|
---|
20 | // Put returns a buffer into the pool.
|
---|
21 | func Put(b *bytes.Buffer) {
|
---|
22 | b.Reset()
|
---|
23 | bpool.Put(b)
|
---|
24 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.