Slight async optimization to the DreamDaemonControlller

Launch multiple tasks so they may execute concurrently before awaiting
This commit is contained in:
Cyberboss
2018-07-10 11:49:22 -04:00
parent 1a1b1f4593
commit cf01b4c60a
@@ -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);