ringbuffer

package
v0.0.0-...-6c4fd92 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: NIST-PD-fallback Imports: 7 Imported by: 1

Documentation

Overview

Package ringbuffer contains bindings of DPDK ring library.

Index

Constants

View Source
const (
	MinCapacity     = 4
	MaxCapacity     = (C.RTE_RING_SZ_MASK + 1) / 2
	DefaultCapacity = 256
)

Limits and defaults.

Variables

This section is empty.

Functions

func AlignCapacity

func AlignCapacity(capacity int, opts ...int) int

AlignCapacity adjusts Ring capacity to a power of two between minimum and maximum. Optional arguments: minimum capacity, default capacity, maximum capacity. Default capacity is used if input is zero.

func Dequeue

func Dequeue[T any, A ~[]T](r *Ring, objs A) (nDequeued int)

Dequeue dequeues several objects.

func Enqueue

func Enqueue[T any, A ~[]T](r *Ring, objs A) (nEnqueued int)

Enqueue enqueues several objects.

Types

type ConsumerMode

type ConsumerMode int

ConsumerMode indicates ring consumer synchronization mode.

const (
	ConsumerMulti  ConsumerMode = 0
	ConsumerSingle ConsumerMode = C.RING_F_SC_DEQ
	ConsumerRts    ConsumerMode = C.RING_F_MC_RTS_DEQ
	ConsumerHts    ConsumerMode = C.RING_F_MC_HTS_DEQ
)

Ring consumer synchronization modes.

type ProducerMode

type ProducerMode int

ProducerMode indicates ring producer synchronization mode.

const (
	ProducerMulti  ProducerMode = 0
	ProducerSingle ProducerMode = C.RING_F_SP_ENQ
	ProducerRts    ProducerMode = C.RING_F_MP_RTS_ENQ
	ProducerHts    ProducerMode = C.RING_F_MP_HTS_ENQ
)

Ring producer synchronization modes.

type Ring

type Ring C.struct_rte_ring

Ring represents a FIFO ring buffer.

func FromPtr

func FromPtr(ptr unsafe.Pointer) *Ring

FromPtr converts *C.struct_rte_ring pointer to Ring.

func New

func New(capacity int, socket eal.NumaSocket, pm ProducerMode, cm ConsumerMode) (r *Ring, e error)

New creates a Ring.

func (*Ring) Capacity

func (r *Ring) Capacity() int

Capacity returns ring capacity.

func (*Ring) Close

func (r *Ring) Close() error

Close releases the ring.

func (*Ring) CountAvailable

func (r *Ring) CountAvailable() int

CountAvailable returns free space.

func (*Ring) CountInUse

func (r *Ring) CountInUse() int

CountInUse returns used space.

func (*Ring) Ptr

func (r *Ring) Ptr() unsafe.Pointer

Ptr returns *C.struct_rte_ring pointer.

func (*Ring) String

func (r *Ring) String() string

Jump to

Keyboard shortcuts

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