ccg

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CQueue

type CQueue[T any] struct {
	// contains filtered or unexported fields
}

CQueue is a lock-free (CAS) unbounded queue. https://www.cs.rochester.edu/u/scott/papers/1996_PODC_queues.pdf

func NewCQueue

func NewCQueue[T any]() *CQueue[T]

NewCQueue returns an empty queue.

func (*CQueue[T]) Clear

func (q *CQueue[T]) Clear()

Clear clears the container

func (*CQueue[T]) IsEmpty

func (q *CQueue[T]) IsEmpty() bool

IsEmpty returns true if the container length == 0

func (*CQueue[T]) Peek

func (q *CQueue[T]) Peek() (T, bool)

Peek Retrieves, but does not remove, the head of this queue, or returns (nil, false) if this queue is empty.

func (*CQueue[T]) Poll

func (q *CQueue[T]) Poll() (T, bool)

Poll Retrieves and removes the head of this queue, or returns (nil, false) if this queue is empty.

func (*CQueue[T]) Push

func (q *CQueue[T]) Push(vs ...T)

Push adds items of vs to the tail of queue

type LQueue

type LQueue[T any] struct {
	// contains filtered or unexported fields
}

LQueue is a concurrent unbounded queue which uses two-Lock concurrent queue qlgorithm.

func NewLQueue

func NewLQueue[T any]() *LQueue[T]

NewLQueue returns an empty LQueue.

func (*LQueue[T]) Clear

func (q *LQueue[T]) Clear()

Clear clears the container

func (*LQueue[T]) IsEmpty

func (q *LQueue[T]) IsEmpty() bool

IsEmpty returns true if the container length == 0

func (*LQueue[T]) Peek

func (q *LQueue[T]) Peek() (T, bool)

Peek Retrieves, but does not remove, the head of this queue, or returns (nil, false) if this queue is empty.

func (*LQueue[T]) Poll

func (q *LQueue[T]) Poll() (T, bool)

Poll Retrieves and removes the head of this queue, or returns (nil, false) if this queue is empty.

func (*LQueue[T]) Push

func (q *LQueue[T]) Push(vs ...T)

Push adds items of vs to the tail of queue

type UnboundedChan

type UnboundedChan[T any] struct {
	In  chan<- T // channel for write
	Out <-chan T // channel for read
	// contains filtered or unexported fields
}

UnboundedChan unbounded channel

func NewUnboundedChan

func NewUnboundedChan[T any](initCapacity int) UnboundedChan[T]

NewUnboundedChan create a unbounded channel

func (UnboundedChan[T]) BufLen

func (ubc UnboundedChan[T]) BufLen() int

BufLen returns len of the buffer.

func (UnboundedChan[T]) Clear

func (ubc UnboundedChan[T]) Clear()

Clear clears the container

func (UnboundedChan[T]) Close

func (ubc UnboundedChan[T]) Close()

Close Close the In channel

func (UnboundedChan[T]) IsEmpty

func (ubc UnboundedChan[T]) IsEmpty() bool

IsEmpty returns true if the container length == 0

func (UnboundedChan[T]) Len

func (ubc UnboundedChan[T]) Len() int

Len returns len of Out plus len of buffer.

func (UnboundedChan[T]) Poll

func (ubc UnboundedChan[T]) Poll() (v T, ok bool)

Poll Retrieves and removes the head of this queue, or returns (nil, false) if this queue is empty.

func (UnboundedChan[T]) Push

func (ubc UnboundedChan[T]) Push(vs ...T)

Push adds items of vs to the tail of queue

Jump to

Keyboard shortcuts

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