{"modulePath":"github.com/infinitbyte/framework","version":"v1.1.5","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package bytebufferpool\n\nPackage bytebufferpool implements a pool of byte buffers with anti-fragmentation protection.\n\nThe pool may waste limited amount of memory due to fragmentation. This amount equals to the maximum total size of the byte buffers in concurrent use.\n\n## Functions\n\n```go\nfunc BuffStats() map[string]interface{}\n```\n\n```go\nfunc CleanupIdleCachedBytesBuffer()\n```\n\n```go\nfunc DumpBufferItemSize() map[string]interface{}\n```\n\n```go\nfunc Put(tag string, b *ByteBuffer)\n```\nPut returns byte buffer to the pool.\n\nByteBuffer.B mustn't be touched after returning it to the pool. Otherwise data races will occur.\n\n```go\nfunc PutWithoutReset(tag string, b *ByteBuffer)\n```\n\n```go\nfunc SetMaxBufferCount(tag string, size uint32)\n```\n\n```go\nfunc SetMaxBufferSize(tag string, size uint32)\n```\n\n## Types\n\n```go\ntype ByteBuffer struct {\n\tLastAccess time.Time\n\tUsed       uint32\n\tID         uint32\n\t// B is a byte buffer to use in append-like workloads.\n\t// See example code for details.\n\tB []byte\n\t// contains filtered or unexported fields\n}\n```\nByteBuffer provides byte buffer, which can be used for minimizing memory allocations.\n\nByteBuffer may be used with functions appending data to the given \\[]byte slice. See example code for details.\n\nUse Get for obtaining an empty byte buffer.\n\n```go\nfunc Get(tag string) *ByteBuffer\n```\nGet returns an empty byte buffer from the pool.\n\nGot byte buffer may be returned to the pool via Put call. This reduces the number of memory allocations required for byte buffer management.\n\n```go\nfunc (b *ByteBuffer) Bytes() []byte\n```\nBytes returns b.B, i.e. all the bytes accumulated in the buffer.\n\nThe purpose of this function is bytes.Buffer compatibility.\n\n```go\nfunc (b *ByteBuffer) Cap() int\n```\n\n```go\nfunc (b *ByteBuffer) GrowTo(n int)\n```\n\n```go\nfunc (b *ByteBuffer) Len() int\n```\nLen returns the size of the byte buffer.\n\n```go\nfunc (b *ByteBuffer) ReadFrom(r io.Reader) (int64, error)\n```\nReadFrom implements io.ReaderFrom.\n\nThe function appends all the data read from r to b.\n\n```go\nfunc (b *ByteBuffer) Reset()\n```\nReset makes ByteBuffer.B empty.\n\n```go\nfunc (b *ByteBuffer) Set(p []byte)\n```\nSet sets ByteBuffer.B to p.\n\n```go\nfunc (b *ByteBuffer) SetString(s string)\n```\nSetString sets ByteBuffer.B to s.\n\n```go\nfunc (b *ByteBuffer) String() string\n```\nString returns string representation of ByteBuffer.B.\n\n```go\nfunc (b *ByteBuffer) Write(p []byte) (int, error)\n```\nWrite implements io.Writer - it appends p to ByteBuffer.B\n\n```go\nfunc (b *ByteBuffer) WriteByte(c byte) error\n```\nWriteByte appends the byte c to the buffer.\n\nThe purpose of this function is bytes.Buffer compatibility.\n\nThe function always returns nil.\n\n```go\nfunc (b *ByteBuffer) WriteBytesArray(ps ...[]byte) (count int, err error)\n```\n\n```go\nfunc (b *ByteBuffer) WriteString(s string) (int, error)\n```\nWriteString appends s to ByteBuffer.B.\n\n```go\nfunc (b *ByteBuffer) WriteTo(w io.Writer) (int64, error)\n```\nWriteTo implements io.WriterTo.\n\n```go\ntype ItemMap struct {\n\tsync.RWMutex\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewItemMap() *ItemMap\n```\n\n```go\nfunc (this *ItemMap) Delete(id uint32)\n```\n\n```go\nfunc (this *ItemMap) Range(f func(key uint32, value *ByteBuffer) bool)\n```\n\n```go\nfunc (this *ItemMap) Store(id uint32, buffer *ByteBuffer)\n```\n\n```go\ntype ObjectPool struct {\n\tNew func() interface{}\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewObjectPool(tag string, allocateFunc func() interface{}, returnCallback func() interface{}, maxItems, maxBytes int) *ObjectPool\n```\n\n```go\nfunc (p *ObjectPool) Get() interface{}\n```\n\n```go\nfunc (p *ObjectPool) Put(o interface{})\n```\n\n```go\ntype Pool struct {\n\tTag string\n\t// contains filtered or unexported fields\n}\n```\nPool represents byte buffer pool.\n\nDistinct pools may be used for distinct types of byte buffers. Properly determined byte buffer types with their own pools may help reducing memory waste.\n\n```go\nfunc NewTaggedPool(tag string, defaultSize, maxSize uint32, maxItems uint32) *Pool\n```\n\n```go\nfunc (p *Pool) Drop(b *ByteBuffer)\n```\n\n```go\nfunc (p *Pool) Get() *ByteBuffer\n```\nGet returns new byte buffer with zero length.\n\nThe byte buffer may be returned to the pool via Put after the use in order to minimize GC overhead.\n\n```go\nfunc (p *Pool) Put(b *ByteBuffer)\n```\n\n","path":"github.com/infinitbyte/framework/lib/bytebufferpool","name":"bytebufferpool","synopsis":"Package bytebufferpool implements a pool of byte buffers with anti-fragmentation protection.","isRedistributable":true}
