Archived
1
This repository has been archived on 2022-11-04. You can view files and clone it, but cannot push or open issues or pull requests.
fwzookeeper/vendor/github.com/kirillDanshin/dlog/buffered_uni.go

31 lines
418 B
Go

package dlog
import (
"sync"
"github.com/valyala/bytebufferpool"
)
// Buffered thread-safe dlog
type Buffered struct {
bb *bytebufferpool.ByteBuffer
sync.RWMutex
}
// NewBuffered dlog
func NewBuffered() *Buffered {
return &Buffered{
bb: bytebufferpool.Get(),
}
}
// Release the buffer for dlog
func (b *Buffered) Release() {
if b.bb == nil {
return
}
b.Lock()
bytebufferpool.Put(b.bb)
b.Unlock()
}