package
Version:
v1.7.0
Opens a new window with list of versions in this module.
Published: Feb 21, 2024
License: Apache-2.0
Opens a new window with license information.
Imports: 0
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
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[T any](channel chan T) Buffer[T]
FromChannel creates a bounded buffer from the given channel.
New creates a new bounded buffer with the given size.
Empty returns true if the buffer is empty.
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 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.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.