Documentation ¶
Overview ¶
Package gqueue 提供了动态/静态的并发安全队列。
特性:
1. 先进先出(FIFO)队列(数据 -> 链表 -> 通道);
2. 快速创建和初始化;
3. 支持动态队列大小(无限制的队列大小);
4. 从队列读取数据时会阻塞等待。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Queue ¶
type Queue struct { C chan interface{} // 数据读取的基础通道。 // contains filtered or unexported fields }
Queue 是一个基于双链表和通道实现的并发安全队列。
func X创建 ¶
New 函数返回一个空的队列对象。 可选参数 `limit` 用于限制队列的大小,默认情况下不限制大小。 当提供了 `limit` 参数时,队列将会是静态且高性能的,其性能可与标准库中的 channel 相媲美。
func (*Queue) X入栈 ¶
func (q *Queue) X入栈(值 interface{})
Push 将数据 `v` 推入队列中。 注意,如果在队列关闭后调用 Push,将会导致程序panic。
Click to show internal directories.
Click to hide internal directories.