Skip to content

Commit 8556362

Browse files
Use PoolingAsyncValueTaskMethodBuilder on various ReadAsync methods. (#35011)
1 parent b88bc69 commit 8556362

File tree

5 files changed

+10
-0
lines changed

5 files changed

+10
-0
lines changed

src/Servers/Kestrel/Core/src/Internal/Http/Http1ContentLengthMessageBody.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Diagnostics;
66
using System.Globalization;
77
using System.IO.Pipelines;
8+
using System.Runtime.CompilerServices;
89
using System.Threading;
910
using System.Threading.Tasks;
1011
using Microsoft.AspNetCore.Connections;
@@ -29,6 +30,7 @@ public Http1ContentLengthMessageBody(Http1Connection context, long contentLength
2930
_unexaminedInputLength = contentLength;
3031
}
3132

33+
[AsyncMethodBuilder(typeof(PoolingAsyncValueTaskMethodBuilder<>))]
3234
public override async ValueTask<ReadResult> ReadAsyncInternal(CancellationToken cancellationToken = default)
3335
{
3436
VerifyIsNotReading();

src/Servers/Kestrel/Core/src/Internal/Http/Http1UpgradeMessageBody.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System;
55
using System.IO.Pipelines;
6+
using System.Runtime.CompilerServices;
67
using System.Threading;
78
using System.Threading.Tasks;
89

@@ -92,6 +93,7 @@ public override ValueTask<ReadResult> ReadAsyncInternal(CancellationToken cancel
9293
return new ValueTask<ReadResult>(readResult);
9394
}
9495

96+
[AsyncMethodBuilder(typeof(PoolingAsyncValueTaskMethodBuilder<>))]
9597
private async ValueTask<ReadResult> ReadAsyncInternalAwaited(ValueTask<ReadResult> readTask, CancellationToken cancellationToken = default)
9698
{
9799
var readResult = await readTask;

src/Servers/Kestrel/Core/src/Internal/Http2/Http2MessageBody.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Diagnostics;
66
using System.Globalization;
77
using System.IO.Pipelines;
8+
using System.Runtime.CompilerServices;
89
using System.Threading;
910
using System.Threading.Tasks;
1011
using Microsoft.AspNetCore.Connections;
@@ -89,6 +90,7 @@ public override bool TryRead(out ReadResult readResult)
8990
return hasResult;
9091
}
9192

93+
[AsyncMethodBuilder(typeof(PoolingAsyncValueTaskMethodBuilder<>))]
9294
public override async ValueTask<ReadResult> ReadAsync(CancellationToken cancellationToken = default)
9395
{
9496
await TryStartAsync();

src/Servers/Kestrel/Core/src/Internal/Http3/Http3MessageBody.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Globalization;
66
using System.IO.Pipelines;
7+
using System.Runtime.CompilerServices;
78
using System.Threading;
89
using System.Threading.Tasks;
910
using Microsoft.AspNetCore.Connections;
@@ -68,6 +69,7 @@ public override bool TryRead(out ReadResult readResult)
6869
return hasResult;
6970
}
7071

72+
[AsyncMethodBuilder(typeof(PoolingAsyncValueTaskMethodBuilder<>))]
7173
public override async ValueTask<ReadResult> ReadAsync(CancellationToken cancellationToken = default)
7274
{
7375
await TryStartAsync();

src/Shared/ServerInfrastructure/DuplexPipeStream.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Threading.Tasks;
99
using System.Buffers;
1010
using Microsoft.AspNetCore.Internal;
11+
using System.Runtime.CompilerServices;
1112

1213
#nullable enable
1314

@@ -112,6 +113,7 @@ public override Task FlushAsync(CancellationToken cancellationToken)
112113
return _output.FlushAsync(cancellationToken).GetAsTask();
113114
}
114115

116+
[AsyncMethodBuilder(typeof(PoolingAsyncValueTaskMethodBuilder<>))]
115117
private async ValueTask<int> ReadAsyncInternal(Memory<byte> destination, CancellationToken cancellationToken)
116118
{
117119
while (true)

0 commit comments

Comments
 (0)