mirror of
https://gitee.com/johng/gf
synced 2026-06-30 19:17:30 +08:00
gqueue新增Close方法便于队列优雅退出
This commit is contained in:
@ -48,6 +48,11 @@ func (q *StringQueue) Pop() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// 关闭队列(通知所有通过Pop阻塞的协程退出)
|
||||
func (q *StringQueue) Close() {
|
||||
q.events <- struct{}{}
|
||||
}
|
||||
|
||||
// 获取当前队列大小
|
||||
func (q *StringQueue) Size() int {
|
||||
return len(q.events)
|
||||
|
||||
Reference in New Issue
Block a user