1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 14:02:55 +08:00

Move lease check inside schedule

Theoretically safer due to avoiding a potential data race (change in
`leasedInProgress` between the time of the check and start of schedule
execution).
This commit is contained in:
Bartłomiej Dach 2021-01-30 21:03:09 +01:00
parent 96f56d1c94
commit 5f320cd426

View File

@ -47,12 +47,12 @@ namespace osu.Game.Screens.OnlinePlay
private void endOperationWithKnownLease(LeasedBindable<bool> lease)
{
if (lease != leasedInProgress)
return;
// for extra safety, marshal the end of operation back to the update thread if necessary.
Scheduler.Add(() =>
{
if (lease != leasedInProgress)
return;
// UnbindAll() is purposefully used instead of Return() - the two do roughly the same thing, with one difference:
// the former won't throw if the lease has already been returned before.
// this matters because framework can unbind the lease via the internal UnbindAllBindables(), which is not always detectable