Ver Fonte

Removed RunLoop from IPlatformThreadingInterface

Nikita Tsukanov há 2 anos atrás
pai
commit
17492be5b6

+ 0 - 2
src/Android/Avalonia.Android/AndroidThreadingInterface.cs

@@ -21,8 +21,6 @@ namespace Avalonia.Android
             _handler = new Handler(App.Context.MainLooper);
         }
 
-        public void RunLoop(CancellationToken cancellationToken) => throw new NotSupportedException();
-
         public IDisposable StartTimer(DispatcherPriority priority, TimeSpan interval, Action tick)
         {
             if (interval.TotalMilliseconds < 10)

+ 0 - 2
src/Avalonia.Base/Platform/IPlatformThreadingInterface.cs

@@ -11,8 +11,6 @@ namespace Avalonia.Platform
     [Unstable]
     public interface IPlatformThreadingInterface
     {
-        void RunLoop(CancellationToken cancellationToken);
-
         /// <summary>
         /// Starts a timer.
         /// </summary>

+ 2 - 1
src/Avalonia.Base/Rendering/Composition/Transport/BatchStreamArrayPool.cs

@@ -30,7 +30,8 @@ internal abstract class BatchStreamPoolBase<T> : IDisposable
             GC.SuppressFinalize(needsFinalize);
 
         var updateRef = new WeakReference<BatchStreamPoolBase<T>>(this);
-        if (AvaloniaLocator.Current.GetService<IPlatformThreadingInterface>() == null)
+        if (AvaloniaLocator.Current.GetService<IPlatformThreadingInterface>() == null
+            && AvaloniaLocator.Current.GetService<IDispatcherImpl>() == null)
             _reclaimImmediately = true;
         else
             StartUpdateTimer(startTimer, updateRef);

+ 1 - 5
src/Avalonia.Base/Threading/IDispatcherImpl.cs

@@ -42,7 +42,7 @@ public interface IControlledDispatcherImpl : IDispatcherImplWithPendingInput
     void RunLoop(CancellationToken token);
 }
 
-internal class LegacyDispatcherImpl : IControlledDispatcherImpl
+internal class LegacyDispatcherImpl : IDispatcherImpl
 {
     private readonly IPlatformThreadingInterface _platformThreading;
     private IDisposable? _timer;
@@ -80,10 +80,6 @@ internal class LegacyDispatcherImpl : IControlledDispatcherImpl
         _timer = null;
         Timer?.Invoke();
     }
-
-    public bool CanQueryPendingInput => false;
-    public bool HasPendingInput => false;
-    public void RunLoop(CancellationToken token) => _platformThreading.RunLoop(token);
 }
 
 class NullDispatcherImpl : IDispatcherImpl

+ 0 - 5
src/Browser/Avalonia.Browser/WindowingPlatform.cs

@@ -49,11 +49,6 @@ namespace Avalonia.Browser
                 .Bind<PlatformHotkeyConfiguration>().ToSingleton<PlatformHotkeyConfiguration>();
         }
 
-        public void RunLoop(CancellationToken cancellationToken)
-        {
-            throw new NotSupportedException();
-        }
-
         public IDisposable StartTimer(DispatcherPriority priority, TimeSpan interval, Action tick)
         {
             return GetRuntimePlatform()

+ 0 - 5
src/iOS/Avalonia.iOS/PlatformThreadingInterface.cs

@@ -14,11 +14,6 @@ namespace Avalonia.iOS
         public bool CurrentThreadIsLoopThread => NSThread.Current.IsMainThread;
         
         public event Action<DispatcherPriority?> Signaled;
-        public void RunLoop(CancellationToken cancellationToken)
-        {
-            //Mobile platforms are using external main loop
-            throw new NotSupportedException(); 
-        }
         
         public IDisposable StartTimer(DispatcherPriority priority, TimeSpan interval, Action tick)
             => NSTimer.CreateRepeatingScheduledTimer(interval, _ => tick());

+ 0 - 5
tests/Avalonia.Base.UnitTests/AvaloniaObjectTests_Threading.cs

@@ -161,11 +161,6 @@ namespace Avalonia.Base.UnitTests
             public event Action<DispatcherPriority?> Signaled;
 #pragma warning restore 67
 
-            public void RunLoop(CancellationToken cancellationToken)
-            {
-                throw new NotImplementedException();
-            }
-
             public void Signal(DispatcherPriority prio)
             {
                 throw new NotImplementedException();

+ 0 - 4
tests/Avalonia.Benchmarks/NullThreadingPlatform.cs

@@ -8,10 +8,6 @@ namespace Avalonia.Benchmarks
 {
     internal class NullThreadingPlatform : IPlatformThreadingInterface
     {
-        public void RunLoop(CancellationToken cancellationToken)
-        {
-        }
-
         public IDisposable StartTimer(DispatcherPriority priority, TimeSpan interval, Action tick)
         {
             return Disposable.Empty;

+ 0 - 5
tests/Avalonia.RenderTests/TestBase.cs

@@ -253,11 +253,6 @@ namespace Avalonia.Direct2D1.RenderTests
             public event Action<DispatcherPriority?> Signaled;
 #pragma warning restore 67
 
-            public void RunLoop(CancellationToken cancellationToken)
-            {
-                throw new NotImplementedException();
-            }
-
             public void Signal(DispatcherPriority prio)
             {
                 // No-op