소스 검색

Removed custom win32 render timer since it leaks pool threads

Nikita Tsukanov 6 년 전
부모
커밋
bca3b42a0c
2개의 변경된 파일1개의 추가작업 그리고 57개의 파일을 삭제
  1. 0 56
      src/Windows/Avalonia.Win32/RenderTimer.cs
  2. 1 1
      src/Windows/Avalonia.Win32/Win32Platform.cs

+ 0 - 56
src/Windows/Avalonia.Win32/RenderTimer.cs

@@ -1,56 +0,0 @@
-using System;
-using System.Reactive.Disposables;
-using System.Threading;
-using Avalonia.Rendering;
-using Avalonia.Win32.Interop;
-
-namespace Avalonia.Win32
-{
-    internal class RenderTimer : DefaultRenderTimer
-    {
-        private UnmanagedMethods.WaitOrTimerCallback timerDelegate;
-
-        private static IntPtr _timerQueue;
-
-        private static void EnsureTimerQueueCreated()
-        {
-            if (Volatile.Read(ref _timerQueue) == null)
-            {
-                var queue = UnmanagedMethods.CreateTimerQueue();
-                if (Interlocked.CompareExchange(ref _timerQueue, queue, IntPtr.Zero) != IntPtr.Zero)
-                {
-                    UnmanagedMethods.DeleteTimerQueueEx(queue, IntPtr.Zero);
-                }
-            }
-        }
-
-        public RenderTimer(int framesPerSecond)
-            : base(framesPerSecond)
-        {
-        }
-
-        protected override IDisposable StartCore(Action<TimeSpan> tick)
-        {
-            EnsureTimerQueueCreated();
-            var msPerFrame = 1000 / FramesPerSecond;
-
-            timerDelegate = (_, __) => tick(TimeSpan.FromMilliseconds(Environment.TickCount));
-
-            UnmanagedMethods.CreateTimerQueueTimer(
-                out var timer,
-                _timerQueue,
-                timerDelegate,
-                IntPtr.Zero,
-                (uint)msPerFrame,
-                (uint)msPerFrame,
-                0
-                );
-
-            return Disposable.Create(() =>
-            {
-                timerDelegate = null;
-                UnmanagedMethods.DeleteTimerQueueTimer(_timerQueue, timer, IntPtr.Zero);
-            });
-        }
-    }
-}

+ 1 - 1
src/Windows/Avalonia.Win32/Win32Platform.cs

@@ -86,7 +86,7 @@ namespace Avalonia.Win32
                 .Bind<IPlatformSettings>().ToConstant(s_instance)
                 .Bind<IPlatformThreadingInterface>().ToConstant(s_instance)
                 .Bind<IRenderLoop>().ToConstant(new RenderLoop())
-                .Bind<IRenderTimer>().ToConstant(new RenderTimer(60))
+                .Bind<IRenderTimer>().ToConstant(new DefaultRenderTimer(60))
                 .Bind<ISystemDialogImpl>().ToSingleton<SystemDialogImpl>()
                 .Bind<IWindowingPlatform>().ToConstant(s_instance)
                 .Bind<PlatformHotkeyConfiguration>().ToSingleton<PlatformHotkeyConfiguration>()