Skip to content

Commit

Permalink
Receive link cleanup (#251)
Browse files Browse the repository at this point in the history
* ReceiveLink static lambdas

* Rename to DrainAsync

* Approve API
  • Loading branch information
danielmarbach authored Jan 16, 2024
1 parent d32534d commit 8d21715
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion api/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ Microsoft.Azure.Amqp.ReceivingAmqpLink.DisposeMessageAsync(System.ArraySegment<b
Microsoft.Azure.Amqp.ReceivingAmqpLink.DisposeMessageAsync(System.ArraySegment<byte> deliveryTag, Microsoft.Azure.Amqp.Framing.Outcome outcome, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<Microsoft.Azure.Amqp.Framing.Outcome>
Microsoft.Azure.Amqp.ReceivingAmqpLink.DisposeMessageAsync(System.ArraySegment<byte> deliveryTag, System.ArraySegment<byte> txnId, Microsoft.Azure.Amqp.Framing.Outcome outcome, bool batchable, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<Microsoft.Azure.Amqp.Framing.Outcome>
Microsoft.Azure.Amqp.ReceivingAmqpLink.DisposeMessageAsync(System.ArraySegment<byte> deliveryTag, System.ArraySegment<byte> txnId, Microsoft.Azure.Amqp.Framing.Outcome outcome, bool batchable, System.TimeSpan timeout) -> System.Threading.Tasks.Task<Microsoft.Azure.Amqp.Framing.Outcome>
Microsoft.Azure.Amqp.ReceivingAmqpLink.DrainAsyc(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task
Microsoft.Azure.Amqp.ReceivingAmqpLink.DrainAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task
Microsoft.Azure.Amqp.ReceivingAmqpLink.EndDisposeMessage(System.IAsyncResult result) -> Microsoft.Azure.Amqp.Framing.Outcome
Microsoft.Azure.Amqp.ReceivingAmqpLink.EndReceiveMessage(System.IAsyncResult result, out Microsoft.Azure.Amqp.AmqpMessage message) -> bool
Microsoft.Azure.Amqp.ReceivingAmqpLink.EndReceiveMessages(System.IAsyncResult result, out System.Collections.Generic.IEnumerable<Microsoft.Azure.Amqp.AmqpMessage> messages) -> bool
Expand Down
10 changes: 5 additions & 5 deletions src/ReceivingAmqpLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,11 @@ public bool EndReceiveMessages(IAsyncResult result, out IEnumerable<AmqpMessage>
/// Drains the credits on the link.
/// </summary>
/// <param name="cancellationToken">A cancellation token that can be used to signal the asynchronous operation should be canceled.</param>
public Task DrainAsyc(CancellationToken cancellationToken)
public Task DrainAsync(CancellationToken cancellationToken)
{
return Task.Factory.FromAsync(
(thisPtr, k, c, s) => new DrainAsyncResult(thisPtr, thisPtr.OperationTimeout, k, c, s),
r => DrainAsyncResult.End(r),
static (thisPtr, k, c, s) => new DrainAsyncResult(thisPtr, thisPtr.OperationTimeout, k, c, s),
static r => DrainAsyncResult.End(r),
this,
cancellationToken,
this);
Expand Down Expand Up @@ -992,7 +992,7 @@ public void Initialize(LinkedListNode<ReceiveAsyncResult> node, CancellationToke

if (cancellationToken.CanBeCanceled)
{
this.cancellationTokenRegistration = cancellationToken.Register(o =>
this.cancellationTokenRegistration = cancellationToken.Register(static o =>
{
ReceiveAsyncResult result = (ReceiveAsyncResult)o;
result.Cancel();
Expand Down Expand Up @@ -1356,4 +1356,4 @@ protected override void CompleteOnTimer()
}
}
}
}
}
2 changes: 1 addition & 1 deletion test/TestCases/AmqpLinkTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ public void AmqpLinkDrainTest()
rLink.AcceptMessage(message);
}

rLink.DrainAsyc(CancellationToken.None).GetAwaiter().GetResult();
rLink.DrainAsync(CancellationToken.None).GetAwaiter().GetResult();
Assert.Equal(0u, rLink.LinkCredit);
Assert.False(rLink.Drain);

Expand Down
2 changes: 1 addition & 1 deletion test/TestCases/CancellationTokenTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ async Task RunLinkDrainTest(bool cancelBefore, int timeoutMilliseconds = 0)
link.Settings.OperationTimeout = TimeSpan.FromMilliseconds(timeoutMilliseconds);
}

var task = link.DrainAsyc(cts.Token);
var task = link.DrainAsync(cts.Token);
if (!cancelBefore && timeoutMilliseconds == 0)
{
await Task.Yield();
Expand Down

0 comments on commit 8d21715

Please sign in to comment.