bbuffer

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer[T any] chan T

Buffer is a bounded buffer, which is a queue with a fixed size. Operations are blocking if the buffer is full or empty.

func FromChannel

func FromChannel[T any](channel chan T) Buffer[T]

FromChannel creates a bounded buffer from the given channel.

func New

func New[T any](size int) Buffer[T]

New creates a new bounded buffer with the given size.

func (Buffer[T]) Empty

func (buffer Buffer[T]) Empty() bool

Empty returns true if the buffer is empty.

func (Buffer[T]) PopFront

func (buffer Buffer[T]) PopFront() T

PopFront removes and returns the value at the front of the buffer. If the buffer is empty, the operation blocks until there is a value available.

func (Buffer[T]) PushBack

func (buffer Buffer[T]) PushBack(value T)

PushBack adds the given value to the back of the buffer. If the buffer is full, the operation blocks until there is space available.

Jump to

Keyboard shortcuts

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