Add update thread assertions

This commit is contained in:
smoogipoo 2021-05-21 15:57:31 +09:00
parent 7ad6a1d5ff
commit 2fdf8aa1aa
1 changed files with 7 additions and 0 deletions

View File

@ -10,6 +10,7 @@
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Development;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Online.API;
@ -144,6 +145,8 @@ Task ISpectatorClient.UserSentFrames(int userId, FrameDataBundle data)
public void BeginPlaying(GameplayBeatmap beatmap, Score score)
{
Debug.Assert(ThreadSafety.IsUpdateThread);
if (IsPlaying)
throw new InvalidOperationException($"Cannot invoke {nameof(BeginPlaying)} when already playing");
@ -172,6 +175,8 @@ public void EndPlaying()
public void WatchUser(int userId)
{
Debug.Assert(ThreadSafety.IsUpdateThread);
if (watchingUsers.Contains(userId))
return;
@ -219,6 +224,8 @@ protected override void Update()
public void HandleFrame(ReplayFrame frame)
{
Debug.Assert(ThreadSafety.IsUpdateThread);
if (frame is IConvertibleReplayFrame convertible)
pendingFrames.Enqueue(convertible.ToLegacy(currentBeatmap));