1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:20:04 +08:00

Ensure PollingComponent.Poll is always called from the update thread

Not strictly required since all `Poll` implementations are now
threadsafe, but extra safety is never a bad thing?
This commit is contained in:
Dean Herbert 2022-01-28 13:44:09 +09:00
parent c44af4853d
commit c953a5d503

View File

@ -2,8 +2,10 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using osu.Framework.Bindables;
using osu.Framework.Development;
using osu.Framework.Graphics.Containers;
using osu.Framework.Threading;
@ -66,6 +68,8 @@ namespace osu.Game.Online
private void doPoll()
{
Debug.Assert(ThreadSafety.IsUpdateThread);
scheduledPoll = null;
pollingActive = true;
Poll().ContinueWith(_ => pollComplete());
@ -96,13 +100,13 @@ namespace osu.Game.Online
if (!lastTimePolled.HasValue)
{
doPoll();
Scheduler.AddOnce(doPoll);
return;
}
if (Time.Current - lastTimePolled.Value > TimeBetweenPolls.Value)
{
doPoll();
Scheduler.AddOnce(doPoll);
return;
}