Race condition on `Registry.setSystemDeltaSeconds`
bfreis opened this issue · comments
Bruno Franca dos Reis commented
Hi!
It seems that there's a race condition in Registry.setSystemDeltaSeconds
, or I might be misunderstanding something.
This is the minimal example that reproduces the issue:
func TestRaceCondition(t *testing.T) {
reg := ecsgo.New()
ecsgo.AddSystem(reg, ecsgo.OnTick, func(r *ecsgo.Registry) {})
ecsgo.AddSystem(reg, ecsgo.OnTick, func(r *ecsgo.Registry) {})
reg.Tick(1.0)
}
Running the snippet above with the race detector reveals the race. The goroutines launched for each of the systems end up calling setSystemDeltaSeconds(...)
which write to r.sysDeltaSeconds
, but there's no synchronization.
Any suggestions?
Thanks!