pointerstore

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MmapSlab

func MmapSlab(conf AllocConfig) (objects, metadata []uintptr)

func MunmapSlab

func MunmapSlab(ptr uintptr, allocConf AllocConfig) error

Types

type AllocConfig

type AllocConfig struct {
	RequestedObjectSize uint64
	RequestedSlabSize   uint64
	//
	ObjectsPerSlab    uint64
	ObjectSize        uint64
	TotalObjectSize   uint64
	MetadataSize      uint64
	TotalMetadataSize uint64
	TotalSlabSize     uint64
}

func NewAllocConfigBySize

func NewAllocConfigBySize(requestedObjectSize uint64, requestedSlabSize uint64) AllocConfig

type RefPointer

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

The address field holds a pointer to an object, but also sneaks a generation value in the top 8 bits of the metaAddress field.

The generation must be masked out to get a usable pointer value. The object pointed to must have the same generation value in order to access/free that object.

func NewReference

func NewReference(pAddress, pMetadata uintptr) RefPointer

func (*RefPointer) AllocFromFree

func (r *RefPointer) AllocFromFree() (nextFree RefPointer)

func (*RefPointer) Bytes

func (r *RefPointer) Bytes(size int) []byte

Convenient method to retrieve raw data of an allocation

func (*RefPointer) DataPtr

func (r *RefPointer) DataPtr() uintptr

func (*RefPointer) Free

func (r *RefPointer) Free(oldFree RefPointer)

func (*RefPointer) Gen

func (r *RefPointer) Gen() uint8

func (*RefPointer) IsNil

func (r *RefPointer) IsNil() bool

func (*RefPointer) Realloc

func (r *RefPointer) Realloc() RefPointer

This method re-allocates the memory location. When this method returns r will no longer be a valid reference. The reference returned _will_ be a valid reference to the same location.

type Stats

type Stats struct {
	Allocs    int
	Frees     int
	RawAllocs int
	Live      int
	Reused    int
	Slabs     int
}

type Store

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

func New

func New(allocConf AllocConfig) *Store

func (*Store) Alloc

func (s *Store) Alloc() RefPointer

func (*Store) AllocConfig

func (s *Store) AllocConfig() AllocConfig

func (*Store) Destroy

func (s *Store) Destroy() error

func (*Store) Free

func (s *Store) Free(r RefPointer)

func (*Store) Stats

func (s *Store) Stats() Stats

Jump to

Keyboard shortcuts

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