Skip to content

Commit

Permalink
Remove reference to _pendingOperations when completed
Browse files Browse the repository at this point in the history
  • Loading branch information
ReubenBond committed Aug 6, 2024
1 parent 5ebaff4 commit 55c87b4
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Orleans.Runtime/Catalog/ActivationData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -872,18 +872,15 @@ private async Task RunMessageLoop()
{
if (!IsCurrentlyExecuting)
{
Queue<object>? operations = null;
bool hasPendingOperations;
lock (this)
{
if (_pendingOperations is { Count: > 0 })
{
operations = _pendingOperations;
}
hasPendingOperations = _pendingOperations is { Count: > 0 };
}

if (operations is not null)
if (hasPendingOperations)
{
await ProcessOperationsAsync(operations);
await ProcessOperationsAsync();
}
}

Expand Down Expand Up @@ -1097,24 +1094,27 @@ bool MayInvokeRequest(Message incoming)
return false;
}

async Task ProcessOperationsAsync(Queue<object> operations)
async Task ProcessOperationsAsync()
{
object? op = null;
while (true)
{
lock (this)
{
Debug.Assert(_pendingOperations is not null);

// Remove the previous operation.
// Operations are not removed until they are completed, allowing for them to see each other.
// Eg, a deactivation request can see any on-going activation request and cancel it.
if (op is not null)
{
operations.Dequeue();
_pendingOperations.Dequeue();
}

// Try to get the next operation.
if (!operations.TryPeek(out op))
if (!_pendingOperations.TryPeek(out op))
{
_pendingOperations = null;
return;
}
}
Expand Down

0 comments on commit 55c87b4

Please sign in to comment.