mirror of
https://github.com/osukey/osukey.git
synced 2025-05-29 09:27:18 +09: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:
parent
c44af4853d
commit
c953a5d503
@ -2,8 +2,10 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Development;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
|
|
||||||
@ -66,6 +68,8 @@ namespace osu.Game.Online
|
|||||||
|
|
||||||
private void doPoll()
|
private void doPoll()
|
||||||
{
|
{
|
||||||
|
Debug.Assert(ThreadSafety.IsUpdateThread);
|
||||||
|
|
||||||
scheduledPoll = null;
|
scheduledPoll = null;
|
||||||
pollingActive = true;
|
pollingActive = true;
|
||||||
Poll().ContinueWith(_ => pollComplete());
|
Poll().ContinueWith(_ => pollComplete());
|
||||||
@ -96,13 +100,13 @@ namespace osu.Game.Online
|
|||||||
|
|
||||||
if (!lastTimePolled.HasValue)
|
if (!lastTimePolled.HasValue)
|
||||||
{
|
{
|
||||||
doPoll();
|
Scheduler.AddOnce(doPoll);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Time.Current - lastTimePolled.Value > TimeBetweenPolls.Value)
|
if (Time.Current - lastTimePolled.Value > TimeBetweenPolls.Value)
|
||||||
{
|
{
|
||||||
doPoll();
|
Scheduler.AddOnce(doPoll);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user