Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PoolChain ¶ added in v1.2.0
type PoolChain struct {
// contains filtered or unexported fields
}
poolChain is a dynamically-sized version of poolDequeue.
This is implemented as a doubly-linked list queue of poolDequeues where each dequeue is double the size of the previous one. Once a dequeue fills up, this allocates a new one and only ever pushes to the latest dequeue. Pops happen from the other end of the list and once a dequeue is exhausted, it gets removed from the list.
func NewPoolChain ¶ added in v1.2.0
func NewPoolChain() *PoolChain
type PoolChainElt ¶ added in v1.2.0
type PoolChainElt struct { PoolDequeue // contains filtered or unexported fields }
把双向链结构,元素放dequeue,每个节点都是一个dequeues(PoolDequeue)
type PoolDequeue ¶
type PoolDequeue struct {
// contains filtered or unexported fields
}
PoolDequeue is a lock-free fixed-size single-producer, multi-consumer queue. The single producer can both push and pop from the head, and consumers can pop from the tail.
It has the added feature that it nils out unused slots to avoid unnecessary retention of objects. This is important for sync.Pool, but not typically a property considered in the literature.
func (*PoolDequeue) PopHead ¶
func (d *PoolDequeue) PopHead() (any, bool)
popHead removes and returns the element at the head of the queue. It returns false if the queue is empty. It must only be called by a single producer.
func (*PoolDequeue) PopTail ¶
func (d *PoolDequeue) PopTail() (any, bool)
popTail removes and returns the element at the tail of the queue. It returns false if the queue is empty. It may be called by any number of consumers.
func (*PoolDequeue) PushHead ¶
func (d *PoolDequeue) PushHead(val any) bool
pushHead adds val at the head of the queue. It returns false if the queue is full. It must only be called by a single producer.
type PoolDequeueI ¶
func NewPoolDequeue ¶
func NewPoolDequeue(initSize int) PoolDequeueI
ring buffer资料结构,容量固定 push一律推到head pop可以head或是tail 可作FIFO也可LIFO