mempool

package
v0.0.0-...-1e60831 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: NIST-PD-fallback Imports: 8 Imported by: 0

Documentation

Overview

Package mempool contains bindings of DPDK memory pool.

Index

Constants

This section is empty.

Variables

View Source
var (
	GqlMemoryDiagType *graphql.Object
)

GraphQL types.

Functions

func Alloc

func Alloc[T any, A ~[]T](mp *Mempool, objs A) error

Alloc allocates several objects.

func ComputeCacheSize

func ComputeCacheSize(capacity int) int

ComputeCacheSize calculates the appropriate cache size for given mempool capacity.

func ComputeOptimumCapacity

func ComputeOptimumCapacity(capacity int) int

ComputeOptimumCapacity adjusts mempool capacity to be a power of two minus one, if near.

func Free

func Free[T any, A ~[]T](mp *Mempool, objs A)

Free releases several objects.

Types

type Config

type Config struct {
	Capacity    int
	ElementSize int
	PrivSize    int
	Socket      eal.NumaSocket

	SingleProducer bool
	SingleConsumer bool
}

Config contains Mempool configuration.

type Mempool

type Mempool C.struct_rte_mempool

Mempool represents a DPDK memory pool for generic objects.

func FromPtr

func FromPtr(ptr unsafe.Pointer) *Mempool

FromPtr converts *C.struct_rte_mempool pointer to Mempool.

func New

func New(cfg Config) (mp *Mempool, e error)

New creates a Mempool.

func (*Mempool) Close

func (mp *Mempool) Close() error

Close releases the mempool.

func (*Mempool) CountAvailable

func (mp *Mempool) CountAvailable() int

CountAvailable returns number of available objects.

func (*Mempool) CountInUse

func (mp *Mempool) CountInUse() int

CountInUse returns number of allocated objects.

func (*Mempool) Ptr

func (mp *Mempool) Ptr() unsafe.Pointer

Ptr returns *C.struct_rte_mempool pointer.

func (*Mempool) SizeofElement

func (mp *Mempool) SizeofElement() int

SizeofElement returns element size.

func (*Mempool) String

func (mp *Mempool) String() string

Jump to

Keyboard shortcuts

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