Tidied structure of all classes within the entire code base
Also some other small bits of tidying
This commit is contained in:
@@ -81,6 +81,10 @@ int Application::run(const std::vector<std::string>& arguments) {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
bool Application::isRunningAsRoot() {
|
||||
return geteuid() == 0;
|
||||
}
|
||||
|
||||
void Application::startup() {
|
||||
auto applicationEventListener = this->applicationEventListener;
|
||||
this->eventManager.registerListener(applicationEventListener);
|
||||
@@ -131,6 +135,37 @@ void Application::startup() {
|
||||
Thread::setThreadState(ThreadState::READY);
|
||||
}
|
||||
|
||||
void Application::shutdown() {
|
||||
auto appState = Thread::getThreadState();
|
||||
if (appState == ThreadState::STOPPED || appState == ThreadState::SHUTDOWN_INITIATED) {
|
||||
return;
|
||||
}
|
||||
|
||||
Thread::setThreadState(ThreadState::SHUTDOWN_INITIATED);
|
||||
Logger::info("Shutting down Bloom");
|
||||
|
||||
this->stopDebugServer();
|
||||
this->stopTargetController();
|
||||
|
||||
if (this->signalHandler.getThreadState() != ThreadState::STOPPED
|
||||
&& this->signalHandler.getThreadState() != ThreadState::UNINITIALISED
|
||||
) {
|
||||
// Signal handler is still running
|
||||
this->signalHandler.triggerShutdown();
|
||||
|
||||
// Send meaningless signal to the SignalHandler thread to have it shutdown.
|
||||
pthread_kill(this->signalHandlerThread.native_handle(), SIGUSR1);
|
||||
}
|
||||
|
||||
if (this->signalHandlerThread.joinable()) {
|
||||
Logger::debug("Joining SignalHandler thread");
|
||||
this->signalHandlerThread.join();
|
||||
Logger::debug("SignalHandler thread joined");
|
||||
}
|
||||
|
||||
Thread::setThreadState(ThreadState::STOPPED);
|
||||
}
|
||||
|
||||
ApplicationConfig Application::extractConfig() {
|
||||
auto appConfig = ApplicationConfig();
|
||||
auto currentPath = std::filesystem::current_path().string();
|
||||
@@ -227,37 +262,6 @@ int Application::initProject() {
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
void Application::shutdown() {
|
||||
auto appState = Thread::getThreadState();
|
||||
if (appState == ThreadState::STOPPED || appState == ThreadState::SHUTDOWN_INITIATED) {
|
||||
return;
|
||||
}
|
||||
|
||||
Thread::setThreadState(ThreadState::SHUTDOWN_INITIATED);
|
||||
Logger::info("Shutting down Bloom");
|
||||
|
||||
this->stopDebugServer();
|
||||
this->stopTargetController();
|
||||
|
||||
if (this->signalHandler.getThreadState() != ThreadState::STOPPED
|
||||
&& this->signalHandler.getThreadState() != ThreadState::UNINITIALISED
|
||||
) {
|
||||
// Signal handler is still running
|
||||
this->signalHandler.triggerShutdown();
|
||||
|
||||
// Send meaningless signal to the SignalHandler thread to have it shutdown.
|
||||
pthread_kill(this->signalHandlerThread.native_handle(), SIGUSR1);
|
||||
}
|
||||
|
||||
if (this->signalHandlerThread.joinable()) {
|
||||
Logger::debug("Joining SignalHandler thread");
|
||||
this->signalHandlerThread.join();
|
||||
Logger::debug("SignalHandler thread joined");
|
||||
}
|
||||
|
||||
Thread::setThreadState(ThreadState::STOPPED);
|
||||
}
|
||||
|
||||
void Application::startTargetController() {
|
||||
this->targetController.setApplicationConfig(this->applicationConfig);
|
||||
this->targetController.setEnvironmentConfig(this->environmentConfig);
|
||||
@@ -354,7 +358,3 @@ void Application::onDebugServerThreadStateChanged(const Events::DebugServerThrea
|
||||
this->shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
bool Application::isRunningAsRoot() {
|
||||
return geteuid() == 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user