pacgo
pacgo copied to clipboard
Some race-condition may not get addressed,I am not sure
` var pillTimer *time.Timer var pillMx sync.Mutex
func processPill() { pillMx.Lock() updateGhosts(ghosts, GhostStatusBlue) if pillTimer != nil { pillTimer.Stop() } pillTimer = time.NewTimer(time.Second * cfg.PillDurationSecs) pillMx.Unlock() <-pillTimer.C /gorotine a gets here,next to execute is pillMx.Lock(),but goroutine b gets control(the lock is free now.)execute from the beginning of the funtion to this line,blocked by pillTimer channel.however gorotine a now get the lock,it continues ,in this case,will ghosts get normal?/ pillMx.Lock() pillTimer.Stop() updateGhosts(ghosts, GhostStatusNormal) pillMx.Unlock() }
it's in step10 main.go.
Hi Alan, please review issue #38. IMHO. this is where the concurrency issues start in step6. If issue #38 is fixed, we need to rework fully the waiting period for a dead player and the structure of the source. There must be a new game loop for every player created. This will probably affect the pill behavior too.