allocator

package
v0.0.0-...-9ad5c47 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Allocator

type Allocator interface {
	// Allocate a new memory block
	//
	// Returns the block id (any), the block data and a possible error
	// The block id will be used to free the block
	Alloc(size int) (any, []byte, error)

	// Free a memory block by an id
	Free(id any) error

	// Closes the allocator, thus freeing all allocated resources
	Close() error
}

Allocator is an interface that wraps the basic allocation interface

The memory allocated using this method will act as a physical memory and will be used by other logic with a page managenet system

type Memory

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

Memory is an allocator that uses go garbage collector for block allocation

func NewMemory

func NewMemory() *Memory

Creates a new allocator that uses golang memory management

func (Memory) Alloc

func (m Memory) Alloc(size int) (any, []byte, error)

func (Memory) Close

func (m Memory) Close() error

func (Memory) Free

func (m Memory) Free(id any) error

Jump to

Keyboard shortcuts

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