优化代码结构,移除未使用的依赖和冗余代码

This commit is contained in:
1
2026-01-26 14:12:12 +00:00
parent c42650145d
commit 1a95ce8c48
6 changed files with 50 additions and 27 deletions

View File

@@ -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()
// }