soc

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package soc has utilities for working with sockets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Read

func Read(conn io.Reader, freeMemory *MemPool, toBeDeserialized chan *Data)

Read reads a socket sending the read data to toBeDeserialized. This should be run in it's own go routine.

Types

type Data

type Data struct {
	Buf []byte
	Err error
	// contains filtered or unexported fields
}

Data is the bytes & error that were read from a socket. When data's bytes are no longer used data must be released.

func (*Data) Release

func (d *Data) Release()

Release frees the underlying array to be reused.

type MemPool

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

MemPool is a pool of allocated memory slabs.

func NewMemPool

func NewMemPool(slabCount, slabSize int) *MemPool

NewMemPool returns a new MemPool.

func (*MemPool) Acquire

func (p *MemPool) Acquire() []byte

Acquire returns a memory slab. The returned slab is owned by the caller. The caller must Release() the slab to the pool when the slab is no longer in use.

func (*MemPool) Release

func (p *MemPool) Release(buf []byte)

Release returns ownership of a slab to the pool.

Jump to

Keyboard shortcuts

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