Jelajahi Sumber

Removing unused code.

Bart De Smet 8 tahun lalu
induk
melakukan
925216010a

+ 0 - 75
Ix.NET/Source/System.Interactive.Async/System/Linq/AsyncEnumerableEx.cs

@@ -2,84 +2,9 @@
 // The .NET Foundation licenses this file to you under the Apache 2.0 License.
 // See the LICENSE file in the project root for more information. 
 
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Threading.Tasks;
-
 namespace System.Linq
 {
     public static partial class AsyncEnumerableEx
     {
-        private static IAsyncEnumerator<T> CreateEnumerator<T>(Func<TaskCompletionSource<bool>, Task<bool>> moveNext, Func<T> current, Func<Task> dispose)
-        {
-            var self = new AnonymousAsyncIterator<T>(
-                async () =>
-                {
-                    var tcs = new TaskCompletionSource<bool>();
-
-                    return await moveNext(tcs).ConfigureAwait(false);
-                },
-                current,
-                dispose
-            );
-
-            return self;
-        }
-
-        private sealed class AnonymousAsyncIterator<T> : AsyncIterator<T>
-        {
-            private readonly Func<T> currentFunc;
-            private readonly Func<Task> dispose;
-            private readonly Func<Task<bool>> moveNext;
-
-            public AnonymousAsyncIterator(Func<Task<bool>> moveNext, Func<T> currentFunc, Func<Task> dispose)
-            {
-                Debug.Assert(moveNext != null);
-
-                this.moveNext = moveNext;
-                this.currentFunc = currentFunc;
-                this.dispose = dispose;
-
-                // Explicit call to initialize enumerator mode
-                GetAsyncEnumerator();
-            }
-
-            public override AsyncIterator<T> Clone()
-            {
-                throw new NotSupportedException("AnonymousAsyncIterator cannot be cloned. It is only intended for use as an iterator.");
-            }
-
-            public override async Task DisposeAsync()
-            {
-                if (dispose != null)
-                {
-                    await dispose().ConfigureAwait(false);
-                }
-
-                await base.DisposeAsync().ConfigureAwait(false);
-            }
-
-            protected override async Task<bool> MoveNextCore()
-            {
-                switch (state)
-                {
-                    case AsyncIteratorState.Allocated:
-                        state = AsyncIteratorState.Iterating;
-                        goto case AsyncIteratorState.Iterating;
-
-                    case AsyncIteratorState.Iterating:
-                        if (await moveNext().ConfigureAwait(false))
-                        {
-                            current = currentFunc();
-                            return true;
-                        }
-
-                        await DisposeAsync().ConfigureAwait(false);
-                        break;
-                }
-
-                return false;
-            }
-        }
     }
 }

+ 11 - 1
Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/Never.cs

@@ -3,6 +3,7 @@
 // See the LICENSE file in the project root for more information. 
 
 using System.Collections.Generic;
+using System.Threading.Tasks;
 
 namespace System.Linq
 {
@@ -10,7 +11,16 @@ namespace System.Linq
     {
         public static IAsyncEnumerable<TValue> Never<TValue>()
         {
-            return AsyncEnumerable.CreateEnumerable(() => CreateEnumerator<TValue>(tcs => tcs.Task, current: null, dispose: null));
+            //
+            // REVIEW: The C# 8.0 proposed interfaces don't allow for cancellation, so this "Never" is
+            //         as never as never can be; it can't be interrupted *at all*, similar to the sync
+            //         variant in Ix. Passing a *hot* CancellationToken to the Never operator doesn't
+            //         seem correct either, given that we return a *cold* sequence.
+            //
+
+            var tcs = new TaskCompletionSource<bool>();
+
+            return AsyncEnumerable.CreateEnumerable(() => AsyncEnumerable.CreateEnumerator<TValue>(() => tcs.Task, current: null, dispose: null));
         }
     }
 }