mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 00:53:22 +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:
parent
96f56d1c94
commit
5f320cd426
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user