A game framework written with osu! in mind.
at master 1.7 kB view raw
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. 2// See the LICENCE file in the repository root for full licence text. 3 4using osu.Framework.Statistics; 5using System; 6using System.Collections.Generic; 7using osu.Framework.Development; 8using osu.Framework.Platform; 9 10namespace osu.Framework.Threading 11{ 12 public class UpdateThread : GameThread 13 { 14 private readonly DrawThread drawThread; 15 16 public UpdateThread(Action onNewFrame, DrawThread drawThread) 17 : base(onNewFrame, "Update") 18 { 19 this.drawThread = drawThread; 20 } 21 22 protected sealed override void OnInitialize() 23 { 24 if (ThreadSafety.ExecutionMode != ExecutionMode.SingleThread) 25 { 26 //this was added due to the dependency on GLWrapper.MaxTextureSize begin initialised. 27 drawThread?.WaitUntilInitialized(); 28 } 29 } 30 31 public override bool IsCurrent => ThreadSafety.IsUpdateThread; 32 33 internal sealed override void MakeCurrent() 34 { 35 base.MakeCurrent(); 36 37 ThreadSafety.IsUpdateThread = true; 38 } 39 40 internal override IEnumerable<StatisticsCounterType> StatisticsCounters => new[] 41 { 42 StatisticsCounterType.Invalidations, 43 StatisticsCounterType.Refreshes, 44 StatisticsCounterType.DrawNodeCtor, 45 StatisticsCounterType.DrawNodeAppl, 46 StatisticsCounterType.ScheduleInvk, 47 StatisticsCounterType.InputQueue, 48 StatisticsCounterType.PositionalIQ, 49 StatisticsCounterType.CCL 50 }; 51 } 52}