Documentation
¶
Overview ¶
----------------------------------------------------------------- * P u b l i c D o m a i n / F O S * Copyright (C)2025 Muhammad H. Hosseinpour, * Copyright (C)2025 Dídimo Grimaldo T. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * A generic interface to the RingQueue implementations (plain & safe) * offered by this GO module. *-----------------------------------------------------------------
----------------------------------------------------------------- * P u b l i c D o m a i n / F O S * Copyright (C)2023 Serge Toro, and * Copyright (C)2025 Muhammad H. Hosseinpour * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Serge Toro's original RingQueue with M. Hadi's enhancements. *-----------------------------------------------------------------
----------------------------------------------------------------- * P u b l i c D o m a i n / F O S * Copyright (C)2023 Serge Toro, and * Copyright (C)2025 Didimo Grimaldo * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * A rune-specific version that does not have the overhead of generics. *-----------------------------------------------------------------
----------------------------------------------------------------- * P u b l i c D o m a i n / F O S * Copyright (C)2025 Muhammad H. Hosseinpour, * Copyright (C)2025 Dídimo Grimaldo T. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * M. Hadi's enhancements on the original RingQueue with my changes * to improve the constructor and implement new IRingQueue methods. *-----------------------------------------------------------------
----------------------------------------------------------------- * P u b l i c D o m a i n / F O S * Copyright (C)2023 Serge Toro, and * Copyright (C)2025 Muhammad H. Hosseinpour * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Serge Toro's original RingQueue with M. Hadi's enhancements. *-----------------------------------------------------------------
Index ¶
- Variables
- func NewSafeRingQueue[T any](capacity int, whenFull WhenFull, whenEmpty WhenEmpty, ...) *safeRQ[T]
- type IRingQueue
- type OnCloseCallback
- type RingQueue
- func (r *RingQueue[T]) Cap() int
- func (r *RingQueue[T]) Close() error
- func (r *RingQueue[T]) IsFull() bool
- func (r *RingQueue[T]) Peek() (T, int, error)
- func (r *RingQueue[T]) Pop() (T, int, error)
- func (r *RingQueue[T]) Push(elem T) (int, error)
- func (r *RingQueue[T]) Reset()
- func (r *RingQueue[T]) SetOnClose(callback OnCloseCallback[T]) IRingQueue[T]
- func (r *RingQueue[T]) SetPopDeadline(t time.Time) error
- func (r *RingQueue[T]) SetWhenFull(a WhenFull) IRingQueue[T]
- func (r *RingQueue[T]) Size() int
- func (r *RingQueue[T]) String() string
- type RuneRingQueue
- func (r *RuneRingQueue) Cap() int
- func (r *RuneRingQueue) Close() error
- func (r *RuneRingQueue) IsFull() bool
- func (r *RuneRingQueue) Peek() (rune, int, error)
- func (r *RuneRingQueue) Pop() (rune, int, error)
- func (r *RuneRingQueue) Push(elem rune) (int, error)
- func (r *RuneRingQueue) Reset()
- func (r *RuneRingQueue) SetOnClose(callback OnCloseCallback[rune]) IRingQueue[rune]
- func (r *RuneRingQueue) SetPopDeadline(t time.Time) error
- func (r *RuneRingQueue) SetWhenFull(a WhenFull) IRingQueue[rune]
- func (r *RuneRingQueue) Size() int
- func (r *RuneRingQueue) String() string
- type SafeCounter
- type WhenEmpty
- type WhenFull
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func NewSafeRingQueue ¶
func NewSafeRingQueue[T any](capacity int, whenFull WhenFull, whenEmpty WhenEmpty, onCloseFunc OnCloseCallback[T]) *safeRQ[T]
Types ¶
type IRingQueue ¶
type IRingQueue[T any] interface { fmt.Stringer io.Closer SetPopDeadline(t time.Time) error SetWhenFull(a WhenFull) IRingQueue[T] SetOnClose(callback OnCloseCallback[T]) IRingQueue[T] Size() int Cap() int Push(element T) (newLen int, err error) Pop() (element T, newLen int, err error) Peek() (element T, len int, err error) Reset() }
type OnCloseCallback ¶
type OnCloseCallback[T any] func(data T)
type RingQueue ¶
type RingQueue[T any] struct { // contains filtered or unexported fields }
func NewRingQueue ¶
func (*RingQueue[T]) SetOnClose ¶
func (r *RingQueue[T]) SetOnClose(callback OnCloseCallback[T]) IRingQueue[T]
func (*RingQueue[T]) SetWhenFull ¶
func (r *RingQueue[T]) SetWhenFull(a WhenFull) IRingQueue[T]
type RuneRingQueue ¶
type RuneRingQueue struct {
// contains filtered or unexported fields
}
*
- A specialized version of the generics RingQueue[T]. First born out
- of curiousity for the benchmark between this and the generic version,
- and also because I was precisely looking for a rune ring buffer for
- my pet project.
func NewRuneRingQueue ¶
func NewRuneRingQueue(capacity int) *RuneRingQueue
*
- A specific (non-generic) Ring Queue to hold unicode runes.
func (*RuneRingQueue) Cap ¶
func (r *RuneRingQueue) Cap() int
func (*RuneRingQueue) Close ¶
func (r *RuneRingQueue) Close() error
*
- Does nothing, simply complies with the interface.
- @implement io.Closer
func (*RuneRingQueue) IsFull ¶
func (r *RuneRingQueue) IsFull() bool
func (*RuneRingQueue) Reset ¶
func (r *RuneRingQueue) Reset()
func (*RuneRingQueue) SetOnClose ¶
func (r *RuneRingQueue) SetOnClose(callback OnCloseCallback[rune]) IRingQueue[rune]
*
- Does nothing, simply complies with the interface.
- @implement roundrobin.IRingQueue[rune]
func (*RuneRingQueue) SetPopDeadline ¶
func (r *RuneRingQueue) SetPopDeadline(t time.Time) error
*
- Throws ErrUnsupported. Simply complies with the interface.
- @implement roundrobin.IRingQueue[rune]
func (*RuneRingQueue) SetWhenFull ¶
func (r *RuneRingQueue) SetWhenFull(a WhenFull) IRingQueue[rune]
*
- Sets the behaviour when pushing onto a full Ring Queue.
- It can throw an error or overwrite old data.
func (*RuneRingQueue) Size ¶
func (r *RuneRingQueue) Size() int
type SafeCounter ¶
type SafeCounter struct {
// contains filtered or unexported fields
}
func NewSafeCounter ¶
func NewSafeCounter() *SafeCounter
func (*SafeCounter) Clear ¶
func (c *SafeCounter) Clear()
func (*SafeCounter) Decrement ¶
func (c *SafeCounter) Decrement() int64
func (*SafeCounter) Increment ¶
func (c *SafeCounter) Increment() int64
func (*SafeCounter) IsZero ¶
func (c *SafeCounter) IsZero() bool
func (*SafeCounter) Value ¶
func (c *SafeCounter) Value() int64