From bd03975a511e0fc2abc86dc54a99ca9c2b732e10 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Tue, 4 Dec 2018 11:30:19 -0500 Subject: [PATCH] Delete dead code in Task Commit migrated from https://github.com/dotnet/coreclr/commit/85f2d14b0c5c44f5669e50d3d6486fa9500aa103 --- .../src/System/Threading/Tasks/future.cs | 70 ---------------------- 1 file changed, 70 deletions(-) diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Threading/Tasks/future.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Threading/Tasks/future.cs index 29309c6..86a6af7 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Threading/Tasks/future.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Threading/Tasks/future.cs @@ -66,9 +66,6 @@ namespace System.Threading.Tasks [DebuggerTypeProxy(typeof(SystemThreadingTasks_FutureDebugView<>))] [DebuggerDisplay("Id = {Id}, Status = {Status}, Method = {DebuggerDisplayMethodDescription}, Result = {DebuggerDisplayResultDescription}")] public class Task : Task -#if SUPPORT_IOBSERVABLE - , IObservable -#endif { internal TResult m_result; // The value itself, if set. @@ -1465,75 +1462,8 @@ namespace System.Threading.Tasks #endregion #endregion - -#if SUPPORT_IOBSERVABLE - /// - /// Subscribes an to receive notification of the final state of this . - /// - /// - /// The to call on task completion. If this Task throws an exception, - /// observer.OnError is called with this Task's AggregateException. If this Task RanToCompletion, - /// observer.OnNext is called with this Task's result, followed by a call to observer.OnCompleted. - /// If this Task is Canceled, observer.OnError is called with a TaskCanceledException - /// containing this Task's CancellationToken - /// - /// An IDisposable object . - /// - /// The argument is null. - /// - IDisposable IObservable.Subscribe(IObserver observer) - { - if (observer == null) - ThrowHelper.ThrowArgumentNullException(ExceptionArgument.observer); - - - var continuationTask = - this.ContinueWith(delegate(Task observedTask, object taskObserverObject) - { - IObserver taskObserver = (IObserver)taskObserverObject; - if (observedTask.IsFaulted) - taskObserver.OnError(observedTask.Exception); - else if (observedTask.IsCanceled) - taskObserver.OnError(new TaskCanceledException(observedTask)); - else - { - taskObserver.OnNext(observedTask.Result); - taskObserver.OnCompleted(); - } - - }, observer, TaskScheduler.Default); - - return new DisposableSubscription(this, continuationTask); - } -#endif } -#if SUPPORT_IOBSERVABLE - // Class that calls RemoveContinuation if Dispose() is called before task completion - internal class DisposableSubscription : IDisposable - { - private Task _notifyObserverContinuationTask; - private Task _observedTask; - - internal DisposableSubscription(Task observedTask, Task notifyObserverContinuationTask) - { - _observedTask = observedTask; - _notifyObserverContinuationTask = notifyObserverContinuationTask; - } - void IDisposable.Dispose() - { - Task localObservedTask = _observedTask; - Task localNotifyingContinuationTask = _notifyObserverContinuationTask; - if (localObservedTask != null && localNotifyingContinuationTask != null && !localObservedTask.IsCompleted) - { - localObservedTask.RemoveContinuation(localNotifyingContinuationTask); - } - _observedTask = null; - _notifyObserverContinuationTask = null; - } - } -#endif - // Proxy class for better debugging experience internal class SystemThreadingTasks_FutureDebugView { -- 2.7.4