mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-27 15:07:03 +01:00
Slight async optimization to the DreamDaemonControlller
Launch multiple tasks so they may execute concurrently before awaiting
This commit is contained in:
@@ -161,14 +161,17 @@ namespace Tgstation.Server.Host.Controllers
|
||||
return Forbid();
|
||||
|
||||
var wd = instanceManager.GetInstance(Instance).Watchdog;
|
||||
await wd.ChangeSettings(current, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var changeSettingsTask = wd.ChangeSettings(current, cancellationToken);
|
||||
|
||||
//soft shutdown/restart can't be cancelled because of how many things rely on them
|
||||
//They can be alternated though
|
||||
if (!oldSoftRestart.Value && current.SoftRestart.Value)
|
||||
await wd.Restart(true, cancellationToken).ConfigureAwait(false);
|
||||
else if (!oldSoftShutdown.Value && current.SoftShutdown.Value)
|
||||
await wd.Terminate(true, cancellationToken).ConfigureAwait(false);
|
||||
//soft shutdown/restart can't be cancelled because of how many things rely on them
|
||||
//They can be alternated though
|
||||
if (!oldSoftRestart.Value && current.SoftRestart.Value)
|
||||
await Task.WhenAll(changeSettingsTask, wd.Restart(true, cancellationToken)).ConfigureAwait(false);
|
||||
else if (!oldSoftShutdown.Value && current.SoftShutdown.Value)
|
||||
await Task.WhenAll(changeSettingsTask, wd.Terminate(true, cancellationToken)).ConfigureAwait(false);
|
||||
else
|
||||
await changeSettingsTask.ConfigureAwait(false);
|
||||
|
||||
await DatabaseContext.Save(default).ConfigureAwait(false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user