优化代码结构,移除未使用的依赖和冗余代码
This commit is contained in:
@@ -8,10 +8,8 @@ import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/panjf2000/ants/v2"
|
||||
)
|
||||
|
||||
// Compare 比较两个1v1战斗动作的执行优先级(核心逻辑)
|
||||
@@ -157,9 +155,10 @@ func (f *FightC) startBattle(startInfo info.FightStartOutboundInfo) {
|
||||
f.startl.Do(func() {
|
||||
|
||||
// 提交战斗循环到战斗池(处理战斗池容量问题)
|
||||
if err := Fightpool.Submit(f.battleLoop); err != nil {
|
||||
log.Panic(context.Background(), "战斗循环提交失败", "error", err)
|
||||
}
|
||||
// if err := Fightpool.Invoke(f); err != nil {
|
||||
// log.Panic(context.Background(), "战斗循环提交失败", "error", err)
|
||||
// }
|
||||
go f.battleLoop()
|
||||
|
||||
f.Broadcast(func(ff *input.Input) {
|
||||
|
||||
@@ -171,9 +170,14 @@ func (f *FightC) startBattle(startInfo info.FightStartOutboundInfo) {
|
||||
|
||||
}
|
||||
|
||||
var Fightpool *ants.Pool
|
||||
// var Fightpool *ants.PoolWithFuncGeneric[*FightC]
|
||||
|
||||
func init() {
|
||||
Fightpool, _ = ants.NewPool(-1)
|
||||
//defer p.Release()
|
||||
}
|
||||
// func init() {
|
||||
// Fightpool, _ = ants.NewPoolWithFuncGeneric(-1, func(f *FightC) {
|
||||
// f.battleLoop()
|
||||
// }, ants.WithPanicHandler(func(a any) {
|
||||
// cool.Logger.Debug(context.Background(), "战斗池发生panic", "error", a)
|
||||
// }),
|
||||
// )
|
||||
// //defer p.Release()
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user