Skip to content

Commit 85b7bfd

Browse files
CopilotReubenBond
andcommitted
Replace lifecycle SystemTarget scheduling with Task.Run
Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>
1 parent 44c61c7 commit 85b7bfd

File tree

3 files changed

+3
-22
lines changed

3 files changed

+3
-22
lines changed

src/Orleans.Core/Runtime/Constants.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ internal static class Constants
1616
public static readonly GrainType CatalogType = SystemTargetGrainId.CreateGrainType("catalog");
1717
public static readonly GrainType MembershipServiceType = SystemTargetGrainId.CreateGrainType("clustering");
1818
public static readonly GrainType SystemMembershipTableType = SystemTargetGrainId.CreateGrainType("clustering.dev");
19-
public static readonly GrainType LifecycleSchedulingSystemTargetType = SystemTargetGrainId.CreateGrainType("lifecycle");
2019
public static readonly GrainType DeploymentLoadPublisherSystemTargetType = SystemTargetGrainId.CreateGrainType("load-publisher");
2120
public static readonly GrainType TestHooksSystemTargetType = SystemTargetGrainId.CreateGrainType("test.hooks");
2221
public static readonly GrainType TransactionAgentSystemTargetType = SystemTargetGrainId.CreateGrainType("txn.agent");
@@ -46,7 +45,6 @@ internal static class Constants
4645
{ClientDirectoryType, "ClientDirectory"},
4746
{CatalogType,"Catalog"},
4847
{MembershipServiceType,"MembershipService"},
49-
{LifecycleSchedulingSystemTargetType, "LifecycleSchedulingSystemTarget"},
5048
{DeploymentLoadPublisherSystemTargetType, "DeploymentLoadPublisherSystemTarget"},
5149
{StreamProviderManagerAgentSystemTargetType,"StreamProviderManagerAgent"},
5250
{TestHooksSystemTargetType,"TestHooksSystemTargetType"},

src/Orleans.Runtime/Hosting/DefaultSiloServices.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ internal static void AddDefaultServices(ISiloBuilder builder)
9393
services.TryAddSingleton<OverloadDetector>();
9494

9595
services.AddSingleton<SystemTargetShared>();
96-
services.AddSingleton<LifecycleSchedulingSystemTarget>();
9796

9897
services.TryAddSingleton<ITimerRegistry, TimerRegistry>();
9998

src/Orleans.Runtime/Silo/Silo.cs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ public sealed partial class Silo : IAsyncDisposable, IDisposable
5353
/// </summary>
5454
public Task SiloTerminated { get { return this.siloTerminatedTask.Task; } } // one event for all types of termination (shutdown, stop and fast kill).
5555

56-
private LifecycleSchedulingSystemTarget lifecycleSchedulingSystemTarget;
57-
5856
/// <summary>
5957
/// Initializes a new instance of the <see cref="Silo"/> class.
6058
/// </summary>
@@ -142,12 +140,9 @@ public Silo(ILocalSiloDetails siloDetails, IServiceProvider services)
142140
/// <returns>A <see cref="Task"/> representing the operation.</returns>
143141
public async Task StartAsync(CancellationToken cancellationToken)
144142
{
145-
// SystemTarget for provider init calls
146-
this.lifecycleSchedulingSystemTarget = Services.GetRequiredService<LifecycleSchedulingSystemTarget>();
147-
148143
try
149144
{
150-
await this.lifecycleSchedulingSystemTarget.WorkItemGroup.QueueTask(() => this.siloLifecycle.OnStart(cancellationToken), lifecycleSchedulingSystemTarget);
145+
await Task.Run(() => this.siloLifecycle.OnStart(cancellationToken), cancellationToken);
151146
}
152147
catch (Exception exc)
153148
{
@@ -344,7 +339,7 @@ public async Task StopAsync(CancellationToken cancellationToken)
344339

345340
try
346341
{
347-
await this.lifecycleSchedulingSystemTarget.QueueTask(() => this.siloLifecycle.OnStop(cancellationToken)).ConfigureAwait(false);
342+
await Task.Run(() => this.siloLifecycle.OnStop(cancellationToken), cancellationToken).ConfigureAwait(false);
348343
}
349344
finally
350345
{
@@ -427,8 +422,7 @@ private async Task OnActiveStop(CancellationToken ct)
427422
{
428423
try
429424
{
430-
await lifecycleSchedulingSystemTarget
431-
.QueueTask(() => this.messageCenter.Gateway.SendStopSendMessages(this.grainFactory)).WaitAsync(ct);
425+
await Task.Run(() => this.messageCenter.Gateway.SendStopSendMessages(this.grainFactory), ct).WaitAsync(ct);
432426
}
433427
catch (Exception exception)
434428
{
@@ -679,14 +673,4 @@ private readonly struct SiloAddressConsistentHashCodeLogValue(SiloAddress siloAd
679673
)]
680674
private static partial void LogDebugGrainServiceStopped(ILogger logger, string grainServiceType, GrainId grainServiceId);
681675
}
682-
683-
// A dummy system target for fallback scheduler
684-
internal sealed class LifecycleSchedulingSystemTarget : SystemTarget
685-
{
686-
public LifecycleSchedulingSystemTarget(SystemTargetShared shared)
687-
: base(Constants.LifecycleSchedulingSystemTargetType, shared)
688-
{
689-
shared.ActivationDirectory.RecordNewTarget(this);
690-
}
691-
}
692676
}

0 commit comments

Comments
 (0)