fixed

package
v0.0.0-...-6fb83e4 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrOverflow returned if requested buffer number larget then max number.
	ErrOverflow = errors.New("buffer number overflow")
)

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	B []byte
	// contains filtered or unexported fields
}

Buffer ...

func (*Buffer) Base

func (b *Buffer) Base() *byte

Base returns pointer to the first byte of the buffer.

func (*Buffer) Bytes

func (b *Buffer) Bytes() []byte

Bytes ...

func (*Buffer) Index

func (b *Buffer) Index() uint16

Index returns bufIndex that must be used for fixed write io_uring operations.

func (*Buffer) Len

func (b *Buffer) Len() uint64

Len ...

type BufferRegistry

type BufferRegistry interface {
	RegisterBuffers([]unix.Iovec) error
}

BufferRegistry ...

type Pool

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

Pool manages registered offheap buffers. Allocated with MAP_ANON | MAP_PRIVATE. TODO performance is not really excellent, several ideas to try: - backoff on contention (runtime.Gosched achieves same purpose) - elimitation array This is much better than mutex-based version (3.5 times faster), but much more worse than simple sync.Pool (10 times slower).

func New

func New(reg BufferRegistry, bufsize, size int) (*Pool, error)

New will initialize mmap'ed memory region, of the total size 16 bytes + size*bufsize and register mmap'ed memory as buffer in io_uring.

func (*Pool) Close

func (p *Pool) Close() error

Close prefents future Get's from the pool and munmap's allocated memory. Caller must ensure that all users of the pool exited before calling Close. Otherwise program will crash referencing to an invalid memory region.

func (*Pool) Get

func (p *Pool) Get() *Buffer

Get buffer.

func (*Pool) Put

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

Put buffer into the pool. Note that if caller won't put used buffer's into the pool Get operation will block indefinitely.

Jump to

Keyboard shortcuts

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