aboutsummaryrefslogtreecommitdiff
path: root/weed/util/buffer_pool/sync_pool.go
blob: b972746915f2a3cd87c08a13fdf10fc7bac15dbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package buffer_pool

import (
	"bytes"
	"sync"
)

var syncPool = sync.Pool{
	New: func() interface{} {
		return new(bytes.Buffer)
	},
}

func SyncPoolGetBuffer() *bytes.Buffer {
	return syncPool.Get().(*bytes.Buffer)
}

func SyncPoolPutBuffer(buffer *bytes.Buffer) {
	syncPool.Put(buffer)
}