【文件属性】:
文件名称:pq:Golang的优先队列
文件大小:5KB
文件格式:ZIP
更新时间:2021-05-23 14:10:22
Go
简单优先级队列
==
创建队列
开始N工人
通过工作程序(同步或异步)执行任务创建任务组(如果需要)
优先处理重要任务
安装:
go get -u github.com/cheggaaa/pq
例子:
package main
import (
"fmt"
"github.com/cheggaaa/pq"
"time"
)
type HardWork struct {
name string
priority int
duration int
}
// implement pq.Task
func ( w * HardWork ) Priority () int {
return w . priority
}
func ( w * HardWork ) Run () ( err error ) {
fmt . Printf ( "Start: %s (%
【文件预览】:
pq-master
----priority.go(558B)
----LICENSE(1KB)
----queue.go(3KB)
----README.md(2KB)
----task.go(270B)
----item.go(590B)
----pq_test.go(2KB)