Skip to content

Commit

Permalink
Avoid over-counting stateless worker activations (dotnet#8886)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReubenBond committed Feb 28, 2024
1 parent eff88b9 commit 9ee8817
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/Orleans.Runtime/Catalog/StatelessWorkerGrainContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ internal class StatelessWorkerGrainContext : IGrainContext, IAsyncDisposable, IA
_innerActivator = innerActivator;
_maxWorkers = ((StatelessWorkerPlacement)_shared.PlacementStrategy).MaxLocal;
_messageLoopTask = Task.Run(RunMessageLoop);
_shared.OnCreateActivation(this);
}

public GrainReference GrainReference => _grainReference ??= _shared.GrainReferenceActivator.CreateReference(GrainId, default);
Expand Down Expand Up @@ -91,16 +90,9 @@ public void Deactivate(DeactivationReason deactivationReason, CancellationToken?

public async ValueTask DisposeAsync()
{
try
{
var completion = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
_workItems.Enqueue(new(WorkItemType.DisposeAsync, new DisposeAsyncWorkItemState(completion)));
await completion.Task;
}
finally
{
_shared.OnDestroyActivation(this);
}
var completion = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
_workItems.Enqueue(new(WorkItemType.DisposeAsync, new DisposeAsyncWorkItemState(completion)));
await completion.Task;
}

public bool Equals([AllowNull] IGrainContext other) => other is not null && ActivationId.Equals(other.ActivationId);
Expand Down

0 comments on commit 9ee8817

Please sign in to comment.