ringbuffer

package
v1.6.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2022 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Put

func Put(b *RingBuffer)

Put returns byte buffer to the pool.

ByteBuffer.B mustn't be touched after returning it to the pool. Otherwise data races will occur.

Types

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool represents ring-buffer pool.

Distinct pools may be used for distinct types of byte buffers. Properly determined byte buffer types with their own pools may help reducing memory waste.

func (*Pool) Get

func (p *Pool) Get() *RingBuffer

Get returns new byte buffer with zero length.

The byte buffer may be returned to the pool via Put after the use in order to minimize GC overhead.

func (*Pool) GetWithSize

func (p *Pool) GetWithSize(size int) *RingBuffer

GetWithSize is like Pool.Get(), but with initial size.

func (*Pool) Put

func (p *Pool) Put(b *RingBuffer)

Put releases byte buffer obtained via Get to the pool.

The buffer mustn't be accessed after returning to the pool.

type RingBuffer

type RingBuffer = ringbuffer.RingBuffer

RingBuffer is the alias of ringbuffer.RingBuffer.

func Get

func Get() *RingBuffer

Get returns an empty byte buffer from the pool.

Got byte buffer may be returned to the pool via Put call. This reduces the number of memory allocations required for byte buffer management.

func GetWithSize

func GetWithSize(size int) *RingBuffer

GetWithSize is like Get(), but with initial size.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL