revert: round 并发安全问题回撤(死锁问题)
This commit is contained in:
parent
5259e07a32
commit
6e11c5edec
|
@ -5,7 +5,6 @@ import (
|
|||
"github.com/kercylan98/minotaur/utils/random"
|
||||
"github.com/kercylan98/minotaur/utils/slice"
|
||||
"github.com/kercylan98/minotaur/utils/timer"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -67,7 +66,7 @@ type Round[Data RoundData] struct {
|
|||
actionTimeoutEventHandles []RoundActionTimeoutEvent[Data] // 行动超时事件
|
||||
actionRefreshEventHandles []RoundActionRefreshEvent[Data] // 行动刷新事件
|
||||
|
||||
actionMutex sync.Mutex
|
||||
//actionMutex sync.Mutex
|
||||
}
|
||||
|
||||
// GetData 获取游戏数据
|
||||
|
@ -80,8 +79,8 @@ func (slf *Round[Data]) GetData() Data {
|
|||
func (slf *Round[Data]) Start() {
|
||||
slf.currentEntity = -1
|
||||
slf.round = 1
|
||||
slf.actionMutex.Lock()
|
||||
defer slf.actionMutex.Unlock()
|
||||
//slf.actionMutex.Lock()
|
||||
//defer slf.actionMutex.Unlock()
|
||||
slf.loop(false)
|
||||
}
|
||||
|
||||
|
@ -163,8 +162,8 @@ func (slf *Round[Data]) SkipCamp() {
|
|||
func (slf *Round[Data]) ActionRefresh() {
|
||||
slf.actionTimeoutTime = time.Now().Add(slf.actionTimeout).Unix()
|
||||
slf.ticker.After(slf.actionTimeoutTickerName, slf.actionTimeout, func(timeout bool) {
|
||||
slf.actionMutex.Lock()
|
||||
defer slf.actionMutex.Unlock()
|
||||
//slf.actionMutex.Lock()
|
||||
//defer slf.actionMutex.Unlock()
|
||||
slf.loop(timeout)
|
||||
}, true)
|
||||
}
|
||||
|
@ -175,8 +174,8 @@ func (slf *Round[Data]) ActionFinish() {
|
|||
if slf.shareAction {
|
||||
slf.currentEntity = -1
|
||||
}
|
||||
slf.actionMutex.Lock()
|
||||
defer slf.actionMutex.Unlock()
|
||||
//slf.actionMutex.Lock()
|
||||
//defer slf.actionMutex.Unlock()
|
||||
slf.loop(false)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue