Skip to content

Commit 5c7a139

Browse files
authored
Consistently use Task or ValueTask in APIs (#1646)
Fixes #1645 * Start with `IFrameHandler` as pointed out by @danielmarbach
1 parent 8d10b43 commit 5c7a139

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

projects/RabbitMQ.Client/client/impl/AutorecoveringConnection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public async ValueTask<RecoveryAwareChannel> CreateNonRecoveringChannelAsync(Can
183183
public override string ToString()
184184
=> $"AutorecoveringConnection({InnerConnection.Id},{Endpoint},{GetHashCode()})";
185185

186-
internal Task CloseFrameHandlerAsync()
186+
internal ValueTask CloseFrameHandlerAsync()
187187
{
188188
return InnerConnection.FrameHandler.CloseAsync(CancellationToken.None);
189189
}

projects/RabbitMQ.Client/client/impl/IFrameHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ internal interface IFrameHandler
5454
///<summary>Socket write timeout. System.Threading.Timeout.InfiniteTimeSpan signals "infinity".</summary>
5555
TimeSpan WriteTimeout { set; }
5656

57-
Task CloseAsync(CancellationToken cancellationToken);
57+
ValueTask CloseAsync(CancellationToken cancellationToken);
5858

5959
///<summary>Read a frame from the underlying
6060
///transport. Returns null if the read operation timed out
@@ -66,7 +66,7 @@ internal interface IFrameHandler
6666
///</summary>
6767
bool TryReadFrame(InboundFrame frame);
6868

69-
Task SendProtocolHeaderAsync(CancellationToken cancellationToken);
69+
ValueTask SendProtocolHeaderAsync(CancellationToken cancellationToken);
7070

7171
ValueTask WriteAsync(RentedMemory frames, CancellationToken cancellationToken);
7272
}

projects/RabbitMQ.Client/client/impl/SocketFrameHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public static async Task<SocketFrameHandler> CreateAsync(AmqpTcpEndpoint amqpTcp
157157
return socketFrameHandler;
158158
}
159159

160-
public async Task CloseAsync(CancellationToken cancellationToken)
160+
public async ValueTask CloseAsync(CancellationToken cancellationToken)
161161
{
162162
if (_closed)
163163
{
@@ -216,7 +216,7 @@ public bool TryReadFrame(InboundFrame frame)
216216
_amqpTcpEndpoint.MaxInboundMessageBodySize, frame);
217217
}
218218

219-
public async Task SendProtocolHeaderAsync(CancellationToken cancellationToken)
219+
public async ValueTask SendProtocolHeaderAsync(CancellationToken cancellationToken)
220220
{
221221
await _pipeWriter.WriteAsync(Amqp091ProtocolHeader, cancellationToken)
222222
.ConfigureAwait(false);

projects/Test/Integration/TestConnectionShutdown.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ public async Task TestDisposedWithSocketClosedOutOfBand()
100100
};
101101

102102
var c = (AutorecoveringConnection)_conn;
103-
Task frameHandlerCloseTask = c.CloseFrameHandlerAsync();
103+
ValueTask frameHandlerCloseTask = c.CloseFrameHandlerAsync();
104104

105105
try
106106
{
107107
_conn.Dispose();
108108
await WaitAsync(tcs, WaitSpan, "channel shutdown");
109-
await frameHandlerCloseTask.WaitAsync(WaitSpan);
109+
await frameHandlerCloseTask.AsTask().WaitAsync(WaitSpan);
110110
}
111111
finally
112112
{

0 commit comments

Comments
 (0)