Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Receive link cleanup #251

Merged
merged 3 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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