Documentation ¶
Overview ¶
Package bufferpool maintains a pool of bytes.Buffers for use in encoding and transport implementations.
Index ¶
- func Put(buf *Buffer)
- type Buffer
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) Len() int
- func (b *Buffer) Read(p []byte) (int, error)
- func (b *Buffer) ReadFrom(r io.Reader) (int64, error)
- func (b *Buffer) Release()
- func (b *Buffer) Reset()
- func (b *Buffer) Write(p []byte) (int, error)
- func (b *Buffer) WriteTo(w io.Writer) (int64, error)
- type Option
- type Pool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer represents a poolable buffer. It wraps an underlying *bytes.Buffer with lightweight detection of races.
func (*Buffer) Bytes ¶
Bytes returns the bytes in the underlying buffer, as well as a function to call when the caller is done using the bytes. This is easy to mis-use and lead to a use-after-free that cannot be detected, so it is strongly recommended that this method is NOT used.
func (*Buffer) Release ¶
func (b *Buffer) Release()
Release releases the buffer back to the buffer pool.
type Option ¶
type Option func(*Pool)
Option configures a buffer pool.
func DetectUseAfterFreeForTests ¶
func DetectUseAfterFreeForTests() Option
DetectUseAfterFreeForTests is an option that allows unit tests to detect bad use of a pooled buffer after it has been released to the pool.