package
Version:
v1.4.7
Opens a new window with list of versions in this module.
Published: Feb 1, 2019
License: MIT
Opens a new window with license information.
Imports: 3
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
Package gqueue provides a dynamic/static concurrent-safe(alternative) queue.
并发安全的动态队列.
特点:
1. 动态队列初始化速度快;
2. 动态的队列大小(不限大小);
3. 取数据时如果队列为空那么会阻塞等待;
type Queue struct {
C chan interface{}
}
1、这是一个先进先出的队列(chan <-- list);
2、当创建Queue对象时限定大小,那么等同于一个同步的chan并发安全队列;
3、不限制大小时,list链表用以存储数据,临时chan负责为客户端读取数据,当从chan获取数据时,list往chan中不停补充数据;
4、由于功能主体是chan,那么操作仍然像chan那样具有阻塞效果;
func (q *Queue) Pop() interface{}
从队头先进先出地从队列取出一项数据
func (q *Queue) Push(v interface{})
将数据压入队列, 队尾
Source Files
¶
Click to show internal directories.
Click to hide internal directories.