Documentation
¶
Index ¶
- Variables
- type Arena
- type AtomicArena
- func (a *AtomicArena[T]) Allocate(sz int) (unsafe.Pointer, error)
- func (a *AtomicArena[T]) AppendSlice(slice []T, elems ...T) ([]T, error)
- func (a *AtomicArena[T]) Base() unsafe.Pointer
- func (a *AtomicArena[T]) NewObject(obj T) (*T, error)
- func (a *AtomicArena[T]) Offset() int
- func (a *AtomicArena[T]) Reset()
- type ConcurrentArena
- func (c *ConcurrentArena[T]) Allocate(sz int) (unsafe.Pointer, error)
- func (c *ConcurrentArena[T]) AppendSlice(slice []T, elems ...T) ([]T, error)
- func (ca *ConcurrentArena[T]) Base() unsafe.Pointer
- func (c *ConcurrentArena[T]) NewObject(obj T) (*T, error)
- func (c *ConcurrentArena[T]) Offset() int
- func (c *ConcurrentArena[T]) Reset()
- type MemoryArena
- func (a *MemoryArena[T]) Allocate(sz int) (unsafe.Pointer, error)
- func (a *MemoryArena[T]) AppendSlice(slice []T, elems ...T) ([]T, error)
- func (a *MemoryArena[T]) Base() unsafe.Pointer
- func (a *MemoryArena[T]) NewObject(obj T) (*T, error)
- func (a *MemoryArena[T]) Offset() int
- func (a *MemoryArena[T]) Reset()
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrOutOfMemory = errors.New("memory arena: out of memory") ErrArenaFull = errors.New("memory arena: insufficient space") ErrInvalidSize = errors.New("memory arena: size must be greater than 0") ErrNewSizeTooSmall = errors.New("memory arena: new size is smaller than current usage") ErrInvalidType = errors.New("memory arena: invalid object type for this arena") )
Functions ¶
This section is empty.
Types ¶
type Arena ¶
type Arena[T any] interface { // Allocate reserves sz bytes (aligned for T) and returns a pointer to the start. Allocate(sz int) (unsafe.Pointer, error) // NewObject allocates space for one T, copies obj into it, and returns *T. NewObject(obj T) (*T, error) // Reset clears all allocations and resets the arena to empty state. Reset() // AppendSlice appends elems to an existing slice, growing in-arena if needed. AppendSlice(slice []T, elems ...T) ([]T, error) Offset() int Base() unsafe.Pointer }
func NewAtomicArena ¶ added in v1.10.15
NewAtomicArena allocates an arena with at least `size` bytes of usable space. Returned addresses are naturally aligned for *T.
type AtomicArena ¶ added in v1.10.15
type AtomicArena[T any] struct { // contains filtered or unexported fields }
func (*AtomicArena[T]) Allocate ¶ added in v1.10.15
func (a *AtomicArena[T]) Allocate(sz int) (unsafe.Pointer, error)
Allocate reserves sz bytes from the arena, aligned to T's alignment, returning a pointer.
func (*AtomicArena[T]) AppendSlice ¶ added in v1.10.27
func (a *AtomicArena[T]) AppendSlice(slice []T, elems ...T) ([]T, error)
AppendSlice appends elems to slice backed by this arena, resizing via the arena when needed.
func (*AtomicArena[T]) Base ¶ added in v1.10.29
func (a *AtomicArena[T]) Base() unsafe.Pointer
func (*AtomicArena[T]) NewObject ¶ added in v1.10.27
func (a *AtomicArena[T]) NewObject(obj T) (*T, error)
NewObject allocates space for T, copies obj into it, and returns *T.
func (*AtomicArena[T]) Offset ¶ added in v1.10.29
func (a *AtomicArena[T]) Offset() int
func (*AtomicArena[T]) Reset ¶ added in v1.10.15
func (a *AtomicArena[T]) Reset()
Reset zeros used memory and resets the offset to zero. Not safe to call concurrently with Allocate.
type ConcurrentArena ¶
type ConcurrentArena[T any] struct { // contains filtered or unexported fields }
func (*ConcurrentArena[T]) Allocate ¶
func (c *ConcurrentArena[T]) Allocate(sz int) (unsafe.Pointer, error)
func (*ConcurrentArena[T]) AppendSlice ¶ added in v1.10.23
func (c *ConcurrentArena[T]) AppendSlice(slice []T, elems ...T) ([]T, error)
func (*ConcurrentArena[T]) Base ¶ added in v1.10.29
func (ca *ConcurrentArena[T]) Base() unsafe.Pointer
func (*ConcurrentArena[T]) NewObject ¶ added in v1.10.23
func (c *ConcurrentArena[T]) NewObject(obj T) (*T, error)
func (*ConcurrentArena[T]) Offset ¶ added in v1.10.29
func (c *ConcurrentArena[T]) Offset() int
func (*ConcurrentArena[T]) Reset ¶
func (c *ConcurrentArena[T]) Reset()
type MemoryArena ¶
type MemoryArena[T any] struct { // contains filtered or unexported fields }
func (*MemoryArena[T]) AppendSlice ¶ added in v1.10.23
func (a *MemoryArena[T]) AppendSlice(slice []T, elems ...T) ([]T, error)
func (*MemoryArena[T]) Base ¶ added in v1.10.29
func (a *MemoryArena[T]) Base() unsafe.Pointer
func (*MemoryArena[T]) NewObject ¶ added in v1.10.23
func (a *MemoryArena[T]) NewObject(obj T) (*T, error)
NewObject allocates space for T by calling Allocate, copies `obj` into it, and returns *T.
func (*MemoryArena[T]) Offset ¶ added in v1.10.29
func (a *MemoryArena[T]) Offset() int
func (*MemoryArena[T]) Reset ¶
func (a *MemoryArena[T]) Reset()
Click to show internal directories.
Click to hide internal directories.