Change our cached task to a field
This makes it more inlinable and saves a volatile lookup on netstandard.
This commit is contained in:
parent
04ffc4d2eb
commit
fb5d92bdc0
|
|
@ -7,23 +7,18 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
{
|
{
|
||||||
public static class TaskCache
|
public static class TaskCache
|
||||||
{
|
{
|
||||||
#if NET451
|
|
||||||
static readonly Task _completedTask = Task.FromResult(0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// <summary>Gets a task that's already been completed successfully.</summary>
|
/// <summary>
|
||||||
/// <remarks>May not always return the same instance.</remarks>
|
/// A <see cref="Task"/> that's already completed successfully.
|
||||||
public static Task CompletedTask
|
/// </summary>
|
||||||
{
|
/// <remarks>
|
||||||
get
|
/// We're caching this in a static readonly field to make it more inlinable and avoid the volatile lookup done
|
||||||
{
|
/// by <c>Task.CompletedTask</c>.
|
||||||
|
/// </remarks>
|
||||||
#if NET451
|
#if NET451
|
||||||
return _completedTask;
|
public static readonly Task CompletedTask = Task.FromResult(0);
|
||||||
#else
|
#else
|
||||||
return Task.CompletedTask;
|
public static readonly Task CompletedTask = Task.CompletedTask;
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue