diff options
| author | Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> | 2024-04-11 16:47:21 +0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-11 04:47:21 -0700 |
| commit | 5189a09de052c799458d5cac2cd0593ac6cacd72 (patch) | |
| tree | 25cf9c8d7957741af6fa24f946aced5007f4cc09 /weed/util | |
| parent | 6dae685f9c17706799b976ad384398418156483c (diff) | |
| download | seaweedfs-5189a09de052c799458d5cac2cd0593ac6cacd72.tar.xz seaweedfs-5189a09de052c799458d5cac2cd0593ac6cacd72.zip | |
[volume] Reduce the number of buffers for uploading one chunk (#5458)
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) +} |
