Documentation ¶
Index ¶
- func InitMetricLoop[T any, TagsT metrics.Tags](uq *UnboundedQueue[T], metricsClient metrics.Client, tags TagsT)
- type Deque
- func (q *Deque[T]) Cap() int
- func (q *Deque[T]) Compact(ratio float64)
- func (q *Deque[T]) GetAndResetLength() int
- func (q *Deque[T]) Len() int
- func (q *Deque[T]) LockedGetAll() [2][]T
- func (q *Deque[T]) LockedPeekFront() (T, bool)
- func (q *Deque[T]) LockedPopFront() (T, bool)
- func (q *Deque[T]) LockedPushBack(obj T)
- func (q *Deque[T]) PopFront() (T, bool)
- func (q *Deque[T]) PushBack(obj T)
- type UnboundedQueue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitMetricLoop ¶
Types ¶
type Deque ¶
type Deque[T any] struct { // contains filtered or unexported fields }
Deque is a typical double-ended queue implemented through a ring buffer.
All operations on Deque locks on its own mutex, so all operations are concurrency-safe.
func NewDeque ¶
NewDeque constructs a new deque with the specified initial capacity.
deque capacity is doubled when the length reaches the capacity, i.e. a deque can never be full.
func (*Deque[T]) GetAndResetLength ¶
func (*Deque[T]) LockedGetAll ¶
func (q *Deque[T]) LockedGetAll() [2][]T
Returns all valid data in two slices.
func (*Deque[T]) LockedPeekFront ¶
func (*Deque[T]) LockedPopFront ¶
func (*Deque[T]) LockedPushBack ¶
func (q *Deque[T]) LockedPushBack(obj T)
type UnboundedQueue ¶
type UnboundedQueue[T any] struct { Close context.CancelFunc // contains filtered or unexported fields }
UnboundedQueue is an unbounded channel.
func NewUnboundedQueue ¶
func NewUnboundedQueue[T any](initialCapacity int) *UnboundedQueue[T]
Creates a new UnboundedQueue with the specified initial capacity.
func (*UnboundedQueue[T]) Length ¶
func (uq *UnboundedQueue[T]) Length() int
func (*UnboundedQueue[T]) Receiver ¶
func (uq *UnboundedQueue[T]) Receiver() <-chan T
Receiver returns the channel that can be used for receiving from this UnboundedQueue.
func (*UnboundedQueue[T]) Send ¶
func (uq *UnboundedQueue[T]) Send(obj T)
Sends an item to the queue.
Since the channel capacity is unbounded, send operations always succeed and never block.