Run user list copy inline if possible

`getRoomUsers()` was not safe to call from the update thread, as
evidenced by the test failures. This was due to the fact that the added
reset event could never actually be set from within the method, as the
wait was blocking the scheduled set from ever proceeding.

Resolve by allowing the scheduled copy & set to run inline if on the
update thread already.
This commit is contained in:
Bartłomiej Dach 2020-12-26 10:59:14 +01:00
parent 5ce5b6cec0
commit dae27fefe4

View File

@ -380,12 +380,12 @@ namespace osu.Game.Online.Multiplayer
// at some point we probably want to replace all these schedule calls with Room.LockForUpdate.
// for now, as this would require quite some consideration due to the number of accesses to the room instance,
// let's just to a schedule for the non-scheduled usages instead.
Schedule(() =>
// let's just add a manual schedule for the non-scheduled usages instead.
Scheduler.Add(() =>
{
users = Room?.Users.ToList();
resetEvent.Set();
});
}, false);
resetEvent.Wait(100);