buf

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2022 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WithFreeWithPool = func(pool IMemoryPool) MemoryFreeFunc {
	return func(node IMemoryNode) {
		pool.Free(node.GetMemoryCapacity())
		node.Reset()
	}
}

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	Node IMemoryNode
}

func (*Buffer) Close

func (b *Buffer) Close() error

func (*Buffer) GetCapacity

func (buf *Buffer) GetCapacity() uint64

func (*Buffer) GetDataNode

func (buf *Buffer) GetDataNode() IMemoryNode

type IBuffer

type IBuffer interface {
	io.Closer
	GetCapacity() uint64
	GetDataNode() IMemoryNode
}

func NewBuffer

func NewBuffer(node IMemoryNode) IBuffer

type IMemoryNode

type IMemoryNode interface {
	io.ReaderFrom
	io.WriterTo
	Marshal() ([]byte, error)
	Unmarshal([]byte) error
	FreeMemory()
	Reset()
	GetMemorySize() uint64
	GetMemoryCapacity() uint64
}

func NewRawMemoryNode

func NewRawMemoryNode(vf common.IVFile, useCompress bool, freeFunc MemoryFreeFunc) IMemoryNode

func RawMemoryNodeConstructor

func RawMemoryNodeConstructor(vf common.IVFile, useCompress bool, freeFunc MemoryFreeFunc) IMemoryNode

type IMemoryPool

type IMemoryPool interface {
	Free(size uint64)
	Alloc(vf common.IVFile, useCompress bool, constructor MemoryNodeConstructor) IMemoryNode
	GetCapacity() uint64
	SetCapacity(uint64) error
	GetUsage() uint64
}

func NewSimpleMemoryPool

func NewSimpleMemoryPool(capacity uint64) IMemoryPool

type MemoryAllocFunc

type MemoryAllocFunc func() (mem []byte, err error)

type MemoryFreeFunc

type MemoryFreeFunc func(IMemoryNode)

type MemoryNodeConstructor

type MemoryNodeConstructor func(common.IVFile, bool, MemoryFreeFunc) IMemoryNode

type RawMemoryNode

type RawMemoryNode struct {
	Data        []byte
	FreeFunc    MemoryFreeFunc
	UseCompress bool
	File        common.IVFile
}

func (*RawMemoryNode) FreeMemory

func (mn *RawMemoryNode) FreeMemory()

func (*RawMemoryNode) GetMemoryCapacity

func (mn *RawMemoryNode) GetMemoryCapacity() uint64

func (*RawMemoryNode) GetMemorySize

func (mn *RawMemoryNode) GetMemorySize() uint64

func (*RawMemoryNode) Marshal

func (mn *RawMemoryNode) Marshal() (buf []byte, err error)

func (*RawMemoryNode) ReadFrom

func (mn *RawMemoryNode) ReadFrom(r io.Reader) (n int64, err error)

func (*RawMemoryNode) Reset

func (mn *RawMemoryNode) Reset()

func (*RawMemoryNode) Unmarshal

func (mn *RawMemoryNode) Unmarshal(buf []byte) error

func (*RawMemoryNode) WriteTo

func (mn *RawMemoryNode) WriteTo(w io.Writer) (n int64, err error)

type SimpleMemoryPool

type SimpleMemoryPool struct {
	Capacity uint64
	Usage    uint64
}

func (*SimpleMemoryPool) Alloc

func (pool *SimpleMemoryPool) Alloc(vf common.IVFile, useCompress bool, constructor MemoryNodeConstructor) (node IMemoryNode)

Only for temp test

func (*SimpleMemoryPool) Free

func (pool *SimpleMemoryPool) Free(size uint64)

func (*SimpleMemoryPool) GetCapacity

func (pool *SimpleMemoryPool) GetCapacity() uint64

func (*SimpleMemoryPool) GetUsage

func (pool *SimpleMemoryPool) GetUsage() uint64

func (*SimpleMemoryPool) SetCapacity

func (pool *SimpleMemoryPool) SetCapacity(capacity uint64) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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