diff options
| author | chrislu <chris.lu@gmail.com> | 2024-04-11 19:48:00 -0700 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2024-04-11 19:48:00 -0700 |
| commit | e53a972483a4c8ad377611f255de205f536f0b19 (patch) | |
| tree | 99a1e290c151e13aee8be3acdce92de4585267e9 /weed/util | |
| parent | cc1c69f312a967dfb636a677db910eb64ab65a06 (diff) | |
| parent | 5189a09de052c799458d5cac2cd0593ac6cacd72 (diff) | |
| download | seaweedfs-e53a972483a4c8ad377611f255de205f536f0b19.tar.xz seaweedfs-e53a972483a4c8ad377611f255de205f536f0b19.zip | |
Merge branch 'master' into mq-subscribe
Diffstat (limited to 'weed/util')
| -rw-r--r-- | weed/util/buffer_pool/sync_pool.go | 20 |
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) +} |
