spool

package
v0.0.0-debug-20260702 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New[T Element](capacity int64, numCursors int) (*Spool[T], []*Cursor[T])

Types

type Cursor

type Cursor[T Element] struct {
	// contains filtered or unexported fields
}

func (*Cursor[T]) Close

func (c *Cursor[T]) Close()

Close closes the cursor

func (*Cursor[T]) FreeCurrent

func (c *Cursor[T]) FreeCurrent()

FreeCurrent decrease reference for last node and check free.

func (*Cursor[T]) Next

func (c *Cursor[T]) Next() (ret T, ok bool)

Next reads the next value if no value is available, Next blocks until value is queued if cursor is closed or no more values can be queued, returns zero value and false

func (*Cursor[T]) Peek

func (c *Cursor[T]) Peek() (ret T, ok bool)

Peek returns the next value if available Peek does not block if no value is available

func (*Cursor[T]) SkipNext

func (c *Cursor[T]) SkipNext()

type Element

type Element interface {
	// SizeInSpool returns the size to occupy in the pool's capacity
	SizeInSpool() int64
	// SpoolFree will be called if no further cursor can see the value
	SpoolFree()
}

type Spool

type Spool[T Element] struct {
	// contains filtered or unexported fields
}

Spool is a single producer multiple consumer queue

func (*Spool[T]) Close

func (s *Spool[T]) Close()

Close closes the spool queued values can still be read

func (*Spool[T]) Send

func (s *Spool[T]) Send(value T)

Send enqueues a value

func (*Spool[T]) SendAny

func (s *Spool[T]) SendAny(value T)

SendAny enqueues a value that at most one cursor can read

func (*Spool[T]) SendTo

func (s *Spool[T]) SendTo(target *Cursor[T], value T)

SendTo enqueues a value that only the specified cursor can read

Jump to

Keyboard shortcuts

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