diff --git a/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs index 7e181bf7ed..fa9159527d 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs @@ -104,7 +104,7 @@ namespace Tgstation.Server.Host.Components.Watchdog => Server?.InstanceRenamed(newInstanceName, cancellationToken) ?? ValueTask.CompletedTask; /// - protected override async Task HandleMonitorWakeup(MonitorActivationReason reason, CancellationToken cancellationToken) + protected override async ValueTask HandleMonitorWakeup(MonitorActivationReason reason, CancellationToken cancellationToken) { switch (reason) { @@ -187,7 +187,7 @@ namespace Tgstation.Server.Host.Components.Watchdog } /// - protected override async Task DisposeAndNullControllersImpl() + protected override async ValueTask DisposeAndNullControllersImpl() { var disposeTask = Server?.DisposeAsync(); gracefulRebootRequired = false; @@ -286,20 +286,20 @@ namespace Tgstation.Server.Host.Components.Watchdog /// Handler for when the is . /// /// The for the operation. - /// A resulting in the to take. - protected virtual Task HandleNormalReboot(CancellationToken cancellationToken) + /// A resulting in the to take. + protected virtual ValueTask HandleNormalReboot(CancellationToken cancellationToken) { var settingsUpdatePending = ActiveLaunchParameters != LastLaunchParameters; var result = settingsUpdatePending ? MonitorAction.Restart : MonitorAction.Continue; - return Task.FromResult(result); + return ValueTask.FromResult(result); } /// /// Handler for . /// /// The for the operation. - /// A representing the running operation. - protected virtual async Task HandleNewDmbAvailable(CancellationToken cancellationToken) + /// A representing the running operation. + protected virtual async ValueTask HandleNewDmbAvailable(CancellationToken cancellationToken) { gracefulRebootRequired = true; if (Server.CompileJob.DMApiVersion == null) @@ -317,7 +317,7 @@ namespace Tgstation.Server.Host.Components.Watchdog /// /// The to be launched. Will not be disposed by this function. /// The for the operation. - /// A resulting in the modified to be used. - protected virtual Task PrepServerForLaunch(IDmbProvider dmbToUse, CancellationToken cancellationToken) => Task.FromResult(dmbToUse); + /// A resulting in the modified to be used. + protected virtual ValueTask PrepServerForLaunch(IDmbProvider dmbToUse, CancellationToken cancellationToken) => ValueTask.FromResult(dmbToUse); } } diff --git a/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs index 044ef3f1ef..841f903677 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs @@ -78,10 +78,10 @@ namespace Tgstation.Server.Host.Components.Watchdog } /// - protected override Task ApplyInitialDmb(CancellationToken cancellationToken) + protected override ValueTask ApplyInitialDmb(CancellationToken cancellationToken) { // not necessary to hold initial .dmb on Linux because of based inode deletes - return Task.CompletedTask; + return ValueTask.CompletedTask; } } } diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs index 1f3190d1c4..a7eb583a7d 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs @@ -568,8 +568,8 @@ namespace Tgstation.Server.Host.Components.Watchdog /// /// Stops . Doesn't kill the servers. /// - /// if the monitor was running, otherwise. - protected async Task StopMonitor() + /// A resulting in if the monitor was running, otherwise. + protected async ValueTask StopMonitor() { Logger.LogTrace("StopMonitor"); if (monitorTask == null) @@ -590,8 +590,8 @@ namespace Tgstation.Server.Host.Components.Watchdog /// The to checkou. /// The name of the server being checked. /// The for the operation. - /// A representing the running operation. - protected async Task CheckLaunchResult(ISessionController controller, string serverName, CancellationToken cancellationToken) + /// A representing the running operation. + protected async ValueTask CheckLaunchResult(ISessionController controller, string serverName, CancellationToken cancellationToken) { var launchResult = await controller.LaunchResult.WaitAsync(cancellationToken); @@ -610,7 +610,7 @@ namespace Tgstation.Server.Host.Components.Watchdog /// Call from when a reattach operation fails to attempt a fresh start. /// /// The for the operation. - /// A representing the running operation. + /// A representing the running operation. protected async ValueTask ReattachFailure(CancellationToken cancellationToken) { // we lost the server, just restart entirely @@ -626,15 +626,15 @@ namespace Tgstation.Server.Host.Components.Watchdog /// /// Call and null the fields for all s. /// - /// A representing the running operation. - protected abstract Task DisposeAndNullControllersImpl(); + /// A representing the running operation. + protected abstract ValueTask DisposeAndNullControllersImpl(); /// /// Wrapper for under a locked context. /// /// The for the operation. - /// A representing the running operation. - protected async Task DisposeAndNullControllers(CancellationToken cancellationToken) + /// A representing the running operation. + protected async ValueTask DisposeAndNullControllers(CancellationToken cancellationToken) { Logger.LogTrace("DisposeAndNullControllers"); using (await SemaphoreSlimContext.Lock(controllerDisposeSemaphore, cancellationToken)) @@ -656,8 +656,8 @@ namespace Tgstation.Server.Host.Components.Watchdog /// /// The that caused the invocation. Will never be . /// The for the operation. - /// A resulting in the to take. - protected abstract Task HandleMonitorWakeup( + /// A resulting in the to take. + protected abstract ValueTask HandleMonitorWakeup( MonitorActivationReason activationReason, CancellationToken cancellationToken); @@ -666,8 +666,8 @@ namespace Tgstation.Server.Host.Components.Watchdog /// /// The new being applied. /// The for the operation. - /// A representing the running operation. - protected async Task BeforeApplyDmb(Models.CompileJob newCompileJob, CancellationToken cancellationToken) + /// A representing the running operation. + protected async ValueTask BeforeApplyDmb(Models.CompileJob newCompileJob, CancellationToken cancellationToken) { if (newCompileJob.Id == ActiveCompileJob?.Id) { @@ -696,7 +696,7 @@ namespace Tgstation.Server.Host.Components.Watchdog /// An of parameters for . /// If the event should be sent to DreamDaemon. /// The for the operation. - /// A representing the running operation. + /// A representing the running operation. protected async ValueTask HandleEventImpl(EventType eventType, IEnumerable parameters, bool relayToSession, CancellationToken cancellationToken) { try @@ -716,8 +716,8 @@ namespace Tgstation.Server.Host.Components.Watchdog /// Attempt to restart the monitor from scratch. /// /// The for the operation. - /// A representing the running operation. - async Task MonitorRestart(CancellationToken cancellationToken) + /// A representing the running operation. + async ValueTask MonitorRestart(CancellationToken cancellationToken) { Logger.LogTrace("Monitor restart!"); @@ -784,7 +784,7 @@ namespace Tgstation.Server.Host.Components.Watchdog /// The main loop of the watchdog. Ayschronously waits for events to occur and then responds to them. /// /// The for the operation. - /// A representing the running operation. + /// A representing the running operation. #pragma warning disable CA1502 async Task MonitorLifetimes(CancellationToken cancellationToken) { @@ -1043,8 +1043,8 @@ namespace Tgstation.Server.Host.Components.Watchdog /// Handles a watchdog health check. /// /// The for the operation. - /// A resulting in the next to take. - async Task HandleHealthCheck(CancellationToken cancellationToken) + /// A resulting in the next to take. + async ValueTask HandleHealthCheck(CancellationToken cancellationToken) { Logger.LogTrace("Sending health check to active server..."); var activeServer = GetActiveController(); diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs index 50980da257..fd1ab5fb18 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs @@ -125,7 +125,7 @@ namespace Tgstation.Server.Host.Components.Watchdog } /// - protected override async Task DisposeAndNullControllersImpl() + protected override async ValueTask DisposeAndNullControllersImpl() { await base.DisposeAndNullControllersImpl(); @@ -138,7 +138,7 @@ namespace Tgstation.Server.Host.Components.Watchdog } /// - protected override async Task HandleNormalReboot(CancellationToken cancellationToken) + protected override async ValueTask HandleNormalReboot(CancellationToken cancellationToken) { if (pendingSwappable != null) { @@ -219,7 +219,7 @@ namespace Tgstation.Server.Host.Components.Watchdog } /// - protected override async Task HandleNewDmbAvailable(CancellationToken cancellationToken) + protected override async ValueTask HandleNewDmbAvailable(CancellationToken cancellationToken) { IDmbProvider compileJobProvider = DmbFactory.LockNextDmb(1); bool canSeamlesslySwap = true; @@ -275,7 +275,7 @@ namespace Tgstation.Server.Host.Components.Watchdog } /// - protected sealed override async Task PrepServerForLaunch(IDmbProvider dmbToUse, CancellationToken cancellationToken) + protected sealed override async ValueTask PrepServerForLaunch(IDmbProvider dmbToUse, CancellationToken cancellationToken) { if (ActiveSwappable != null) throw new InvalidOperationException("Expected activeSwappable to be null!"); @@ -305,7 +305,7 @@ namespace Tgstation.Server.Host.Components.Watchdog /// /// The for the operation. /// A representing the running operation. - protected virtual async Task ApplyInitialDmb(CancellationToken cancellationToken) + protected virtual async ValueTask ApplyInitialDmb(CancellationToken cancellationToken) { Server.ReattachInformation.InitialDmb = await DmbFactory.FromCompileJob(Server.CompileJob, cancellationToken); } @@ -318,7 +318,7 @@ namespace Tgstation.Server.Host.Components.Watchdog } /// - protected override async Task HandleMonitorWakeup(MonitorActivationReason reason, CancellationToken cancellationToken) + protected override async ValueTask HandleMonitorWakeup(MonitorActivationReason reason, CancellationToken cancellationToken) { var result = await base.HandleMonitorWakeup(reason, cancellationToken); if (reason == MonitorActivationReason.ActiveServerStartup)