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/Threading/Tasks/ValueTask.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/Threading/Tasks/ValueTask.cs')
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Threading/Tasks/ValueTask.cs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Threading/Tasks/ValueTask.cs b/src/System.Private.CoreLib/shared/System/Threading/Tasks/ValueTask.cs index 384e4a8ab..4ccf0f8a4 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/Tasks/ValueTask.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/Tasks/ValueTask.cs @@ -116,6 +116,15 @@ namespace System.Threading.Tasks // and the hash code we generate in GetHashCode. _task ?? AsyncTaskMethodBuilder<TResult>.GetTaskForResult(_result); + internal Task<TResult> AsTaskExpectNonNull() => + // Return the task if we were constructed from one, otherwise manufacture one. + // Unlike AsTask(), this method is called only when we expect _task to be non-null, + // and thus we don't want GetTaskForResult inlined. + _task ?? GetTaskForResultNoInlining(); + + [MethodImpl(MethodImplOptions.NoInlining)] + private Task<TResult> GetTaskForResultNoInlining() => AsyncTaskMethodBuilder<TResult>.GetTaskForResult(_result); + /// <summary>Gets whether the <see cref="ValueTask{TResult}"/> represents a completed operation.</summary> public bool IsCompleted => _task == null || _task.IsCompleted; |