Skip to content

Commit 77ae8af

Browse files
mayukiJamesNK
andauthored
Use PoolingAsyncValueTaskMethodBuilder on ReadStreamMessageAsync method (#1850)
Co-authored-by: James Newton-King <james@newtonking.com>
1 parent d250e28 commit 77ae8af

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Grpc.AspNetCore.Server/Internal/PipeExtensions.cs

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using System.Diagnostics;
2222
using System.Diagnostics.CodeAnalysis;
2323
using System.IO.Pipelines;
24+
using System.Runtime.CompilerServices;
2425
using Grpc.Core;
2526
using Grpc.Net.Compression;
2627
using Microsoft.Extensions.Logging;
@@ -280,6 +281,9 @@ public static async ValueTask<T> ReadSingleMessageAsync<T>(this PipeReader input
280281
/// <param name="deserializer">Message deserializer.</param>
281282
/// <param name="cancellationToken">The cancellation token.</param>
282283
/// <returns>Complete message data or null if the stream is complete.</returns>
284+
#if NET6_0_OR_GREATER
285+
[AsyncMethodBuilder(typeof(PoolingAsyncValueTaskMethodBuilder<>))]
286+
#endif
283287
public static async ValueTask<T?> ReadStreamMessageAsync<T>(this PipeReader input, HttpContextServerCallContext serverCallContext, Func<DeserializationContext, T> deserializer, CancellationToken cancellationToken = default)
284288
where T : class
285289
{

0 commit comments

Comments
 (0)