Tidied structure of all classes within the entire code base

Also some other small bits of tidying
This commit is contained in:
Nav
2021-10-06 21:12:31 +01:00
parent 1aef5bba79
commit 6edfb7376a
179 changed files with 3446 additions and 3493 deletions

View File

@@ -8,31 +8,6 @@
using namespace Bloom;
void SignalHandler::startup() {
this->setName("SH");
Thread::setThreadState(ThreadState::STARTING);
Logger::debug("Starting SignalHandler");
// Block all signal interrupts
auto signalSet = this->getRegisteredSignalSet();
sigprocmask(SIG_SETMASK, &signalSet, NULL);
// Register handlers here
this->handlersMappedBySignalNum.insert(std::pair(
SIGINT,
std::bind(&SignalHandler::triggerApplicationShutdown, this)
));
this->handlersMappedBySignalNum.insert(std::pair(
SIGTERM,
std::bind(&SignalHandler::triggerApplicationShutdown, this)
));
// It's possible that the SignalHandler has been instructed to shutdown, before it could finish starting up.
if (this->getThreadState() != ThreadState::SHUTDOWN_INITIATED) {
Thread::setThreadState(ThreadState::READY);
}
}
void SignalHandler::run() {
try {
this->startup();
@@ -58,6 +33,31 @@ void SignalHandler::run() {
Thread::setThreadState(ThreadState::STOPPED);
}
void SignalHandler::startup() {
this->setName("SH");
Thread::setThreadState(ThreadState::STARTING);
Logger::debug("Starting SignalHandler");
// Block all signal interrupts
auto signalSet = this->getRegisteredSignalSet();
sigprocmask(SIG_SETMASK, &signalSet, NULL);
// Register handlers here
this->handlersMappedBySignalNum.insert(std::pair(
SIGINT,
std::bind(&SignalHandler::triggerApplicationShutdown, this)
));
this->handlersMappedBySignalNum.insert(std::pair(
SIGTERM,
std::bind(&SignalHandler::triggerApplicationShutdown, this)
));
// It's possible that the SignalHandler has been instructed to shutdown, before it could finish starting up.
if (this->getThreadState() != ThreadState::SHUTDOWN_INITIATED) {
Thread::setThreadState(ThreadState::READY);
}
}
sigset_t SignalHandler::getRegisteredSignalSet() const {
sigset_t set = {};
if (sigfillset(&set) == -1) {

View File

@@ -10,6 +10,21 @@ namespace Bloom
{
class SignalHandler: public Thread
{
public:
explicit SignalHandler(EventManager& eventManager): eventManager(eventManager) {};
/**
* Entry point for SignalHandler thread.
*/
void run();
/**
* Triggers the shutdown of the SignalHandler thread.
*/
void triggerShutdown() {
this->setThreadState(ThreadState::SHUTDOWN_INITIATED);
};
private:
EventManager& eventManager;
@@ -45,20 +60,5 @@ namespace Bloom
* program immediately if numerous SIGINT signals have been received.
*/
void triggerApplicationShutdown();
public:
explicit SignalHandler(EventManager& eventManager): eventManager(eventManager) {};
/**
* Entry point for SignalHandler thread.
*/
void run();
/**
* Triggers the shutdown of the SignalHandler thread.
*/
void triggerShutdown() {
this->setThreadState(ThreadState::SHUTDOWN_INITIATED);
};
};
}