summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Toub <stoub@microsoft.com>2017-04-18 13:57:19 -0400
committerStephen Toub <stoub@microsoft.com>2017-04-18 13:57:19 -0400
commitcbd3f54c7dbd3808e2d8b1e4dc1040f511147d19 (patch)
treebdf68f28c5fbde366c2a8e04a13c2618817ace46
parentbbe202b1de189812866acfa288ab1ac21a5fecdb (diff)
downloadcoreclr-cbd3f54c7dbd3808e2d8b1e4dc1040f511147d19.tar.gz
coreclr-cbd3f54c7dbd3808e2d8b1e4dc1040f511147d19.tar.bz2
coreclr-cbd3f54c7dbd3808e2d8b1e4dc1040f511147d19.zip
Expose Task.IsCompletedSuccessfully
-rw-r--r--src/mscorlib/shared/System/Threading/Tasks/TaskExtensions.cs4
-rw-r--r--src/mscorlib/src/System/IO/Stream.cs4
-rw-r--r--src/mscorlib/src/System/Runtime/CompilerServices/TaskAwaiter.cs2
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/Task.cs3
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/TaskContinuation.cs2
-rw-r--r--src/mscorlib/src/System/Threading/Tasks/future.cs6
6 files changed, 10 insertions, 11 deletions
diff --git a/src/mscorlib/shared/System/Threading/Tasks/TaskExtensions.cs b/src/mscorlib/shared/System/Threading/Tasks/TaskExtensions.cs
index 1098299517..97f2013d79 100644
--- a/src/mscorlib/shared/System/Threading/Tasks/TaskExtensions.cs
+++ b/src/mscorlib/shared/System/Threading/Tasks/TaskExtensions.cs
@@ -21,7 +21,7 @@ namespace System.Threading.Tasks
// it completed successfully. Return its inner task to avoid unnecessary wrapping, or if the inner
// task is null, return a canceled task to match the same semantics as CreateUnwrapPromise.
return
- !task.IsRanToCompletion ? Task.CreateUnwrapPromise<VoidTaskResult>(task, lookForOce: false) :
+ !task.IsCompletedSuccessfully ? Task.CreateUnwrapPromise<VoidTaskResult>(task, lookForOce: false) :
task.Result ??
Task.FromCanceled(new CancellationToken(true));
}
@@ -40,7 +40,7 @@ namespace System.Threading.Tasks
// it completed successfully. Return its inner task to avoid unnecessary wrapping, or if the inner
// task is null, return a canceled task to match the same semantics as CreateUnwrapPromise.
return
- !task.IsRanToCompletion ? Task.CreateUnwrapPromise<TResult>(task, lookForOce: false) :
+ !task.IsCompletedSuccessfully ? Task.CreateUnwrapPromise<TResult>(task, lookForOce: false) :
task.Result ??
Task.FromCanceled<TResult>(new CancellationToken(true));
}
diff --git a/src/mscorlib/src/System/IO/Stream.cs b/src/mscorlib/src/System/IO/Stream.cs
index 92fe374f19..65cc4ddcb9 100644
--- a/src/mscorlib/src/System/IO/Stream.cs
+++ b/src/mscorlib/src/System/IO/Stream.cs
@@ -522,14 +522,14 @@ namespace System.IO
// If the wait has already completed, run the task.
if (asyncWaiter.IsCompleted)
{
- Debug.Assert(asyncWaiter.IsRanToCompletion, "The semaphore wait should always complete successfully.");
+ Debug.Assert(asyncWaiter.IsCompletedSuccessfully, "The semaphore wait should always complete successfully.");
RunReadWriteTask(readWriteTask);
}
else // Otherwise, wait for our turn, and then run the task.
{
asyncWaiter.ContinueWith((t, state) =>
{
- Debug.Assert(t.IsRanToCompletion, "The semaphore wait should always complete successfully.");
+ Debug.Assert(t.IsCompletedSuccessfully, "The semaphore wait should always complete successfully.");
var rwt = (ReadWriteTask)state;
rwt._stream.RunReadWriteTask(rwt); // RunReadWriteTask(readWriteTask);
}, readWriteTask, default(CancellationToken), TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default);
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/TaskAwaiter.cs b/src/mscorlib/src/System/Runtime/CompilerServices/TaskAwaiter.cs
index e2fa6caa2d..c35658e54c 100644
--- a/src/mscorlib/src/System/Runtime/CompilerServices/TaskAwaiter.cs
+++ b/src/mscorlib/src/System/Runtime/CompilerServices/TaskAwaiter.cs
@@ -146,7 +146,7 @@ namespace System.Runtime.CompilerServices
task.NotifyDebuggerOfWaitCompletionIfNecessary();
// And throw an exception if the task is faulted or canceled.
- if (!task.IsRanToCompletion) ThrowForNonSuccess(task);
+ if (!task.IsCompletedSuccessfully) ThrowForNonSuccess(task);
}
/// <summary>Throws an exception to handle a task that completed in a state other than RanToCompletion.</summary>
diff --git a/src/mscorlib/src/System/Threading/Tasks/Task.cs b/src/mscorlib/src/System/Threading/Tasks/Task.cs
index 8e2e6a4cb0..0a9248cba8 100644
--- a/src/mscorlib/src/System/Threading/Tasks/Task.cs
+++ b/src/mscorlib/src/System/Threading/Tasks/Task.cs
@@ -1467,8 +1467,7 @@ namespace System.Threading.Tasks
return (flags & TASK_STATE_COMPLETED_MASK) != 0;
}
- // For use in InternalWait -- marginally faster than (Task.Status == TaskStatus.RanToCompletion)
- internal bool IsRanToCompletion
+ public bool IsCompletedSuccessfully
{
get { return (m_stateFlags & TASK_STATE_COMPLETED_MASK) == TASK_STATE_RAN_TO_COMPLETION; }
}
diff --git a/src/mscorlib/src/System/Threading/Tasks/TaskContinuation.cs b/src/mscorlib/src/System/Threading/Tasks/TaskContinuation.cs
index 848a0ecbc2..de222352c9 100644
--- a/src/mscorlib/src/System/Threading/Tasks/TaskContinuation.cs
+++ b/src/mscorlib/src/System/Threading/Tasks/TaskContinuation.cs
@@ -320,7 +320,7 @@ namespace System.Threading.Tasks
// activation criteria of the TaskContinuationOptions.
TaskContinuationOptions options = m_options;
bool isRightKind =
- completedTask.IsRanToCompletion ?
+ completedTask.IsCompletedSuccessfully ?
(options & TaskContinuationOptions.NotOnRanToCompletion) == 0 :
(completedTask.IsCanceled ?
(options & TaskContinuationOptions.NotOnCanceled) == 0 :
diff --git a/src/mscorlib/src/System/Threading/Tasks/future.cs b/src/mscorlib/src/System/Threading/Tasks/future.cs
index 26c2388e6b..bf9000ea00 100644
--- a/src/mscorlib/src/System/Threading/Tasks/future.cs
+++ b/src/mscorlib/src/System/Threading/Tasks/future.cs
@@ -374,7 +374,7 @@ namespace System.Threading.Tasks
{
get
{
- return IsRanToCompletion ? "" + m_result : SR.TaskT_DebuggerNoResult;
+ return IsCompletedSuccessfully ? "" + m_result : SR.TaskT_DebuggerNoResult;
}
}
@@ -491,10 +491,10 @@ namespace System.Threading.Tasks
if (waitCompletionNotification) NotifyDebuggerOfWaitCompletionIfNecessary();
// Throw an exception if appropriate.
- if (!IsRanToCompletion) ThrowIfExceptional(includeTaskCanceledExceptions: true);
+ if (!IsCompletedSuccessfully) ThrowIfExceptional(includeTaskCanceledExceptions: true);
// We shouldn't be here if the result has not been set.
- Debug.Assert(IsRanToCompletion, "Task<T>.Result getter: Expected result to have been set.");
+ Debug.Assert(IsCompletedSuccessfully, "Task<T>.Result getter: Expected result to have been set.");
return m_result;
}