allocate

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OsPageSize = os.Getpagesize()

	End = errors.New("END")
)

Functions

This section is empty.

Types

type BytesAllocator

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

func NewBytesAllocator

func NewBytesAllocator(cap int) *BytesAllocator

func (*BytesAllocator) AllocAt

func (bsa *BytesAllocator) AllocAt(offset int64, n int) ([]byte, error)

AllocAt 在分配器中获取[offset:offset+n)范围内的缓存区, 如果offset不在分配器范围则返回END错误,如果offset+n超过分配器上限,则返回的缓存区大小将会小于n

func (*BytesAllocator) Release

func (bsa *BytesAllocator) Release()

func (*BytesAllocator) Resize

func (bsa *BytesAllocator) Resize(size int) error

func (*BytesAllocator) Size

func (bsa *BytesAllocator) Size() int

type MmapAllocator

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

func NewMmapAllocator

func NewMmapAllocator(f *os.File, offset int64, mmSize int, mapPort, mapFlag int, lock bool) (*MmapAllocator, error)

func (*MmapAllocator) AllocAt

func (mal *MmapAllocator) AllocAt(offset int64, n int) ([]byte, error)

AllocAt 在映射区中获取[offset:offset+n)范围内的缓存区, 如果offset不在映射区范围则返回END错误,如果offset+n超过映射区上线,则返回的缓存区大小将会小于n

func (*MmapAllocator) Release

func (mal *MmapAllocator) Release()

Release 释放映射区

func (*MmapAllocator) Resize

func (mal *MmapAllocator) Resize(foffset int64, mmSize int) error

Resize 重映射映射区

func (*MmapAllocator) Size

func (mal *MmapAllocator) Size() int

Size 当前映射区的大小

Jump to

Keyboard shortcuts

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