aboutsummaryrefslogtreecommitdiff
path: root/weed/util/buffer_pool
diff options
context:
space:
mode:
Diffstat (limited to 'weed/util/buffer_pool')
-rw-r--r--weed/util/buffer_pool/sync_pool.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/weed/util/buffer_pool/sync_pool.go b/weed/util/buffer_pool/sync_pool.go
new file mode 100644
index 000000000..b97274691
--- /dev/null
+++ b/weed/util/buffer_pool/sync_pool.go
@@ -0,0 +1,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)
+}