package queue
import "github.com/Azure/go-amqp/internal/queue"
Index ¶
- type Holder
- func NewHolder[T any](q *Queue[T]) *Holder[T]
- func (h *Holder[T]) Acquire() *Queue[T]
- func (h *Holder[T]) Len() int
- func (h *Holder[T]) Release(q *Queue[T])
- func (h *Holder[T]) Wait() <-chan *Queue[T]
- type Queue
Types ¶
type Holder ¶
type Holder[T any] struct { // contains filtered or unexported fields }
Holder provides synchronized access to a *Queue[T].
func NewHolder ¶
NewHolder creates a new Holder[T] that contains the provided *Queue[T].
func (*Holder[T]) Acquire ¶
Acquire attempts to acquire the *Queue[T]. If the *Queue[T] has already been acquired the call blocks. When the *Queue[T] is no longer required, you MUST call Release() to relinquish acquisition.
func (*Holder[T]) Len ¶
Len returns the length of the *Queue[T].
func (*Holder[T]) Release ¶
Release returns the *Queue[T] back to the Holder[T]. Once the *Queue[T] has been released, it is no longer safe to call its methods.
func (*Holder[T]) Wait ¶
Wait returns a channel that's signaled when the *Queue[T] contains at least one item. When the *Queue[T] is no longer required, you MUST call Release() to relinquish acquisition.
type Queue ¶
type Queue[T any] struct { // contains filtered or unexported fields }
Queue[T] is a segmented FIFO queue of Ts.
func New ¶
New creates a new instance of Queue[T].
- size is the size of each Queue segment
func (*Queue[T]) Dequeue ¶
func (q *Queue[T]) Dequeue() *T
Dequeue removes and returns the item from the front of the queue.
func (*Queue[T]) Enqueue ¶
func (q *Queue[T]) Enqueue(item T)
Enqueue adds the specified item to the end of the queue. If the current segment is full, a new segment is created.
func (*Queue[T]) Len ¶
Len returns the total count of enqueued items.
Source Files ¶
- Version
- v1.4.0 (latest)
- Published
- Feb 19, 2025
- Platform
- linux/amd64
- Imports
- 1 packages
- Last checked
- 5 days ago –
Tools for package owners.