ringbuffer

package
v0.0.0-...-c2e30b8 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2021 License: NIST-PD-fallback Imports: 5 Imported by: 1

Documentation

Overview

Package ringbuffer contains bindings of DPDK ring library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlignCapacity

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

AlignCapacity returns an acceptable capacity for Ring. It takes up to three parameters:

capacity: input capacity
min: minimum capacity; default is 64.
dflt: default capacity, if input is less than minimum; default is same as min.

If input capacity is less than minimum, use dflt. Then, adjust to next power of 2.

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
	ConsumerCts    ConsumerMode = C.RING_F_MC_HTS_DEQ
)

Ring consumer synchronzation 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,
	producerMode ProducerMode, consumerMode 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) Dequeue

func (r *Ring) Dequeue(objs interface{}) (nDequeued int)

Dequeue dequeues several objects from a ring. objs should be a slice of C void* pointers.

func (*Ring) Enqueue

func (r *Ring) Enqueue(objs interface{}) (nEnqueued int)

Enqueue enqueues several objects on a ring. objs should be a slice of C void* pointers.

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