diff options
author | Jan Kotas <jkotas@microsoft.com> | 2017-11-09 03:20:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-09 03:20:39 +0300 |
commit | 162cead08753e6440d7e90ec4fb453a1a651785a (patch) | |
tree | dbb0478e51bd5b376386e6d0a38df7037fe51526 /src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs | |
parent | 2bc2edc1e2b1b0e835366668b53ccfc48ece0949 (diff) | |
parent | 0566d28cd25fb5a8b708b94dd9ba7960a75e3b07 (diff) |
Merge pull request #4894 from dotnet/master
Merge master to nmirror
Diffstat (limited to 'src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs')
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs index 203039a4a..0b0ed8595 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; namespace System.Runtime.CompilerServices { /// <summary>Provides an awaiter for a <see cref="ValueTask{TResult}"/>.</summary> - public struct ValueTaskAwaiter<TResult> : ICriticalNotifyCompletion + public struct ValueTaskAwaiter<TResult> : ICriticalNotifyCompletion, IValueTaskAwaiter { /// <summary>The value being awaited.</summary> private ValueTask<TResult> _value; // Methods are called on this; avoid making it readonly so as to avoid unnecessary copies @@ -38,5 +38,17 @@ namespace System.Runtime.CompilerServices /// <summary>Gets the task underlying <see cref="_value"/>.</summary> internal Task<TResult> AsTask() => _value.AsTask(); + + /// <summary>Gets the task underlying the incomplete <see cref="_value"/>.</summary> + /// <remarks>This method is used when awaiting and IsCompleted returned false; thus we expect the value task to be wrapping a non-null task.</remarks> + Task IValueTaskAwaiter.GetTask() => _value.AsTaskExpectNonNull(); + } + + /// <summary> + /// Internal interface used to enable extract the Task from arbitrary ValueTask awaiters. + /// </summary>> + internal interface IValueTaskAwaiter + { + Task GetTask(); } } |