pool

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const BufSize = 20 * 1024

Variables

This section is empty.

Functions

func FreeBytes

func FreeBytes(b []byte)

func NewBytes

func NewBytes(size int) []byte

Types

type Allocator added in v0.9.0

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

Allocator for incoming frames, optimized to prevent overwriting after zeroing

func NewAllocator added in v0.9.0

func NewAllocator() *Allocator

NewAllocator initiates a []byte allocator for frames less than 65536 bytes, the waste(memory fragmentation) of space allocation is guaranteed to be no more than 50%.

func (*Allocator) Get added in v0.9.0

func (alloc *Allocator) Get(size int) []byte

Get a []byte from pool with most appropriate cap

func (*Allocator) Put added in v0.9.0

func (alloc *Allocator) Put(buf []byte) error

Put returns a []byte to pool for future use, which the cap must be exactly 2^n

type Interface added in v0.9.0

type Interface struct {
	io.ReadWriteCloser
	ReadCh chan []byte
	StopCh chan bool
}

func OpenTunDevice added in v0.9.0

func OpenTunDevice(tunFd int) (*Interface, error)

func (*Interface) Copy added in v0.9.0

func (tunDev *Interface) Copy(dst io.Writer)

func (*Interface) Run added in v0.9.0

func (tunDev *Interface) Run(ctx context.Context)

func (*Interface) Stop added in v0.9.0

func (tunDev *Interface) Stop()

Jump to

Keyboard shortcuts

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