//dispatch 调度层包
分为三个文件
centerdispatchlayer.go //调度层
centerdispatch.go //调度器
globals.go //全局类
1:centerdispatchlayer.go
package dispatch
import (
"fmt"
"tools/reptilesoper/reptilesengine/gogo/pools"
"tools/reptilesoper/reptilesengine/gogo/timerupdate"
)
type GoWorkerNum int
const (
MinWorkerNum GoWorkerNum = 1
WorkerNum10 GoWorkerNum = 10
WorkerNum20 GoWorkerNum = 20
WorkerNum50 GoWorkerNum = 50
WorkerNum100 GoWorkerNum = 100
WorkerNum200 GoWorkerNum = 200
WorkerNum500 GoWorkerNum = 500
MaxWorkerNum GoWorkerNum = 999
)
//中心调度层
type CDLayer struct {
CDs []*CenterDispatch
WorkerNum GoWorkerNum //几个工作goroutine
PL *pools.GoPools //协程池
}
//创建调度器
func (cds *CDLayer) CreateCD(name string) *CenterDispatch {
return &CenterDispatch{
Name: name,
ReceiveChannel: make(chan *timerupdate.Task),
}
}
//根据调度器名称返回调度器
func (cds *CDLayer)FindCDByName(cdName string)*CenterDispatch {
for _,v:=range cds.CDs {
if v.Name==cdName {
return v
}
}
return nil
}
//把RC通道里面的任务发送给协程池的对外通道EC
func (cd *CDLayer) SendTaskToEC(