Skip to content

Commit

Permalink
Remove ForceAsync from CryptoStream (#45150)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub committed Nov 25, 2020
1 parent 3e65d68 commit 93cbc09
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 55 deletions.

This file was deleted.

2 changes: 0 additions & 2 deletions src/libraries/System.IO.Pipes/src/System.IO.Pipes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,6 @@
Link="Common\Interop\Unix\Interop.GetEUid.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.SetEUid.cs"
Link="Common\Interop\Unix\Interop.SetEUid.cs" />
<Compile Include="$(CommonPath)System\Threading\Tasks\ForceAsyncAwaiter.cs"
Link="Common\System\Threading\Tasks\ForceAsyncAwaiter.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Collections" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
<Compile Include="System\Security\Cryptography\SymmetricAlgorithm.cs" />
<Compile Include="$(CommonPath)System\Obsoletions.cs"
Link="Common\System\Obsoletions.cs" />
<Compile Include="$(CommonPath)System\Threading\Tasks\ForceAsyncAwaiter.cs"
Link="Common\System\Threading\Tasks\ForceAsyncAwaiter.cs" />
<Compile Include="$(CommonPath)Internal\Cryptography\Helpers.cs"
Link="Internal\Cryptography\Helpers.cs" />
<Compile Include="$(CommonPath)System\Security\Cryptography\CryptoPool.cs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Buffers;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -218,15 +219,14 @@ private async Task<int> ReadAsyncInternal(byte[] buffer, int offset, int count,
// async requests outstanding, we will block the application's main
// thread if it does a second IO request until the first one completes.

SemaphoreSlim semaphore = AsyncActiveSemaphore;
await semaphore.WaitAsync(cancellationToken).ForceAsync();
await AsyncActiveSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
try
{
return await ReadAsyncCore(buffer, offset, count, cancellationToken, useAsync: true).ConfigureAwait(false);
}
finally
{
semaphore.Release();
_lazyAsyncActiveSemaphore.Release();
}
}

Expand Down Expand Up @@ -495,15 +495,14 @@ private async Task WriteAsyncInternal(byte[] buffer, int offset, int count, Canc
// async requests outstanding, we will block the application's main
// thread if it does a second IO request until the first one completes.

SemaphoreSlim semaphore = AsyncActiveSemaphore;
await semaphore.WaitAsync(cancellationToken).ForceAsync();
await AsyncActiveSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
try
{
await WriteAsyncCore(buffer, offset, count, cancellationToken, useAsync: true).ConfigureAwait(false);
}
finally
{
semaphore.Release();
_lazyAsyncActiveSemaphore.Release();
}
}

Expand Down Expand Up @@ -748,6 +747,7 @@ private void InitializeBuffer()
}
}

[MemberNotNull(nameof(_lazyAsyncActiveSemaphore))]
private SemaphoreSlim AsyncActiveSemaphore
{
get
Expand Down

0 comments on commit 93cbc09

Please sign in to comment.