mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-02 00:11:56 +03:00
Correctly manage partial writes
This commit is contained in:
@@ -1,12 +1,22 @@
|
||||
package record
|
||||
|
||||
import "sync"
|
||||
import (
|
||||
"bytes"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var recordPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
return &Record{}
|
||||
},
|
||||
}
|
||||
var (
|
||||
recordPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
return &Record{}
|
||||
},
|
||||
}
|
||||
bytesBufferPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
return &bytes.Buffer{}
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func AcquireRecord() *Record {
|
||||
return recordPool.Get().(*Record)
|
||||
@@ -16,3 +26,12 @@ func ReleaseRecord(r *Record) {
|
||||
r.Reset()
|
||||
recordPool.Put(r)
|
||||
}
|
||||
|
||||
func acquireBytesBuffer() *bytes.Buffer {
|
||||
return bytesBufferPool.Get().(*bytes.Buffer)
|
||||
}
|
||||
|
||||
func releaseBytesBuffer(buf *bytes.Buffer) {
|
||||
buf.Reset()
|
||||
bytesBufferPool.Put(buf)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user