ring

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const SpinMask = 1024 - 1 // arbitrary; we'll want to experiment with different values

Variables

View Source
var ErrMinimumReservationSize = errors.New("the minimum reservation size is 1 slot")
View Source
var (
	ErrNotPowerOf2 = errors.New("not power of 2")
)

Functions

This section is empty.

Types

type Barrier

type Barrier interface {
	Load() int64
}

func NewCompositeBarrier

func NewCompositeBarrier(sequences ...*Cursor) Barrier

type Consumer

type Consumer interface {
	Consume(lower, upper int64)
}

type ConsumerReader

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

func NewReader

func NewReader(
	current, written *Cursor,
	upstream Barrier,
	waiter waiter.Waiter,
	consumer Consumer,
) *ConsumerReader

func (*ConsumerReader) Close

func (r *ConsumerReader) Close() error

func (*ConsumerReader) Read

func (r *ConsumerReader) Read()

type Cursor

type Cursor cpu.CacheLinePad

Cursor prevent false sharing of the sequence cursor by padding the CPU cache line

func NewCursor

func NewCursor() *Cursor

func (*Cursor) Load

func (c *Cursor) Load() int64

func (*Cursor) Store

func (c *Cursor) Store(value int64)

type Data

type Data[T any] interface {
	Cap() int64

	Index(sequence int64) int64

	Get(sequence int64) *T

	Put(sequence int64, value T)
}

type Disruptor

type Disruptor struct {
	Writer
	Reader
}

func New

func New(options ...Option) Disruptor

func NewDisruptor

func NewDisruptor(writer Writer, reader Reader) Disruptor

type MPWriter

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

type Option

type Option func(*Wireup)

func WithCapacity

func WithCapacity(value int64) Option

func WithConsumerGroup

func WithConsumerGroup(value ...Consumer) Option

func WithWaitStrategy

func WithWaitStrategy(value waiter2.Waiter) Option

type Poller

type Poller struct{}

type Reader

type Reader interface {
	io.Closer

	Read()
}

type Ring

type Ring[T any] struct {
	// contains filtered or unexported fields
}

func NewRing

func NewRing[T any](capacity int64) (*Ring[T], error)

func (*Ring[T]) Cap

func (r *Ring[T]) Cap() int64

func (*Ring[T]) Get

func (r *Ring[T]) Get(sequence int64) *T

func (*Ring[T]) Index

func (r *Ring[T]) Index(sequence int64) int64

func (*Ring[T]) Put

func (r *Ring[T]) Put(sequence int64, value T)

type SPSequencer

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

func (*SPSequencer) HasCapacity

func (s *SPSequencer) HasCapacity(required int64, doStore bool) bool

type SPWriter

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

func NewSPWriter

func NewSPWriter(written *Cursor, upstream Barrier, capacity int64) *SPWriter

func (*SPWriter) Commit

func (w *SPWriter) Commit(_, upper int64)

func (*SPWriter) Reserve

func (w *SPWriter) Reserve(count int64) int64

type UnsafeRing

type UnsafeRing[T any] struct {
	// contains filtered or unexported fields
}

func NewUnsafeRing

func NewUnsafeRing[T any](capacity int64) (*UnsafeRing[T], error)

func (*UnsafeRing[T]) Close

func (u *UnsafeRing[T]) Close() error

func (*UnsafeRing[T]) Get

func (r *UnsafeRing[T]) Get(sequence int64) *T

func (*UnsafeRing[T]) Index

func (r *UnsafeRing[T]) Index(sequence int64) int64

func (*UnsafeRing[T]) Put

func (r *UnsafeRing[T]) Put(sequence int64, value T)

type Wireup

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

func NewWireup

func NewWireup(options ...Option) (*Wireup, error)

func (*Wireup) Build

func (w *Wireup) Build() (Writer, Reader)

type Writer

type Writer interface {
	Reserve(count int64) int64

	Commit(lower, upper int64)
}

Jump to

Keyboard shortcuts

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