GracefullyShutdown: Add "subsystem x/y shutting down" message

Remove old "X shutting down", "X shut down" messages, they were bad and
confusing
This commit is contained in:
Lion Kortlepel
2021-09-09 11:58:58 +03:00
committed by Lion
parent d43ee4b7b6
commit b055fd8bda
6 changed files with 14 additions and 14 deletions

View File

@@ -22,11 +22,20 @@ void Application::RegisterShutdownHandler(const TShutdownHandler& Handler) {
}
}
static bool AlreadyShuttingDown = false;
void Application::GracefullyShutdown() {
info("please wait while all subsystems are shutting down...");
if (AlreadyShuttingDown) {
info("already shutting down");
return;
} else {
AlreadyShuttingDown = true;
}
trace("waiting for lock release");
std::unique_lock Lock(mShutdownHandlersMutex);
for (auto& Handler : mShutdownHandlers) {
Handler();
info("please wait while all subsystems are shutting down...");
for (size_t i = 0; i < mShutdownHandlers.size(); ++i) {
info("Subsystem " + std::to_string(i + 1) + "/" + std::to_string(mShutdownHandlers.size()) + " shutting down");
mShutdownHandlers[i]();
}
}