代码拉取完成,页面将自动刷新
package Stragey
import (
"sync"
)
type strategyContext struct {
index int32
max int32
api StrategyApi
}
func (this *strategyContext) reset() {
this.index = 0
this.max = 0
}
func (this *strategyContext) handle() int32 {
return this.api.Exec(this.index, this.max)
}
/**
策略处理
*/
type strategyFactory struct {
pool sync.Pool
}
func NewStrategyFactory() *strategyFactory {
stf := &strategyFactory{}
stf.pool.New = func() any {
return &strategyContext{}
}
return stf
}
func (this *strategyFactory) param(index, max int32, api StrategyApi) *strategyContext {
_c := this.pool.Get().(*strategyContext)
_c.index = index
_c.max = max
_c.api = api
paramC := *_c
_c.reset()
this.pool.Put(_c)
return ¶mC
}
/**
轮询
*/
func (this *strategyFactory) RoundRobin(index, max int32) int32 {
return this.param(index, max, newStrategyRoundRobin()).handle()
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。