未验证 提交 18f1e7f0 编写于 作者: S Sam Harwell 提交者: GitHub

Merge pull request #36128 from sharwell/valuetask-disposablewaitasync

DisposableWaitAsync often completes synchronously
......@@ -14,7 +14,8 @@ public static SemaphoreDisposer DisposableWait(this SemaphoreSlim semaphore, Can
return new SemaphoreDisposer(semaphore);
}
public async static Task<SemaphoreDisposer> DisposableWaitAsync(this SemaphoreSlim semaphore, CancellationToken cancellationToken = default)
[PerformanceSensitive("https://github.com/dotnet/roslyn/issues/36114", OftenCompletesSynchronously = true)]
public async static ValueTask<SemaphoreDisposer> DisposableWaitAsync(this SemaphoreSlim semaphore, CancellationToken cancellationToken = default)
{
await semaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
return new SemaphoreDisposer(semaphore);
......
......@@ -42,6 +42,7 @@
<Compile Include="..\..\Workspaces\Core\Portable\Utilities\NonReentrantLock.cs" Link="Utilities\NonReentrantLock.cs" />
<Compile Include="..\..\Workspaces\Core\Portable\Utilities\ValuesSources\ValueSource.cs" Link="Utilities\ValueSource.cs" />
<Compile Include="..\..\Workspaces\Core\Portable\Utilities\ValuesSources\ConstantValueSource.cs" Link="Utilities\ConstantValueSource.cs" />
<Compile Include="..\..\Compilers\Core\Portable\InternalUtilities\PerformanceSensitiveAttribute.cs" Link="Utilities\PerformanceSensitiveAttribute.cs" />
<Compile Include="..\..\Compilers\Core\Portable\InternalUtilities\SemaphoreSlimExtensions.cs" Link="Utilities\SemaphoreSlimExtensions.cs" />
<Compile Include="..\..\Compilers\Core\Portable\InternalUtilities\ExceptionUtilities.cs" Link="Utilities\ExceptionUtilities.cs" />
<Compile Include="..\..\Compilers\Core\Portable\InternalUtilities\FailFast.cs" Link="Utilities\FailFast.cs" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册