This commit is contained in:
laodaming 2023-09-22 14:29:21 +08:00
parent 366a441cf2
commit e4c165cd18

View File

@ -23,7 +23,7 @@ var (
//每个websocket渲染任务缓冲队列长度默认值
renderChanLen = 500
//每个websocket渲染并发数
renderChanConcurrency = 15
renderChanConcurrency = 3
)
// 渲染处理器
@ -33,6 +33,8 @@ type renderProcessor struct {
// 云渲染属性
type extendRenderProperty struct {
renderChan chan websocket_data.RenderImageReqMsg //渲染消息入口的缓冲队列
selectColorIndex int //颜色选中索引
templateTag string //模板标签
}
// 处理分发到这里的数据
@ -48,6 +50,8 @@ func (r *renderProcessor) allocationMessage(w *wsConnectItem, data []byte) {
case <-w.closeChan: //已经关闭
return
case w.extendRenderProperty.renderChan <- renderImageData: //发入到缓冲队列
w.extendRenderProperty.templateTag = renderImageData.RenderData.TemplateTag
w.extendRenderProperty.selectColorIndex = renderImageData.RenderData.TemplateTagColor.SelectedColorIndex
return
}
}
@ -67,6 +71,14 @@ func (w *wsConnectItem) consumeRenderImageData() {
case <-w.closeChan: //已关闭
return
case data := <-w.extendRenderProperty.renderChan: //消费数据
if data.RenderData.TemplateTag != w.extendRenderProperty.templateTag{
logx.Error("由于模板切换了,丢弃该渲染消息")
continue
}
if data.RenderData.TemplateTagColor.SelectedColorIndex != w.extendRenderProperty.selectColorIndex{
logx.Error("由于模板切换了颜色,丢弃该渲染消息")
continue
}
limitChan <- struct{}{}
go func(d websocket_data.RenderImageReqMsg) {
defer func() {