diff --git a/docs/api/cpp/exceptions.md b/docs/api/cpp/exceptions.md index 31d87cb5a..fc28b1b86 100644 --- a/docs/api/cpp/exceptions.md +++ b/docs/api/cpp/exceptions.md @@ -9,8 +9,6 @@ The declarations of all the enums can be found in the `include/ViZDoomExceptions * `MessageQueueException/SharedMemoryException` - means that communication with ViZDoom's instance failed. Usually, means a problem with permissions or system configuration. -* `SignalException` - means that a signal was cached by ViZDoom's instance. - * `ViZDoomErrorException` - means that an error in the ViZDoom engine occurred. * `ViZDoomIsNotRunningException` - means that called method cannot be used when ViZDoom instance is not running. diff --git a/docs/api/python/exceptions.md b/docs/api/python/exceptions.md index 92843dc43..76a24bea4 100644 --- a/docs/api/python/exceptions.md +++ b/docs/api/python/exceptions.md @@ -20,12 +20,6 @@ Means that communication with ViZDoom's instance failed. Usually, means a proble Means that allocation/reading of shared memory failed. Usually, means a problem with permissions or system configuration. -```{eval-rst} -.. autoexception:: vizdoom.SignalException -``` - -Means that a signal was cached by ViZDoom's instance. - ```{eval-rst} .. autoexception:: vizdoom.ViZDoomErrorException ``` diff --git a/include/ViZDoomExceptions.h b/include/ViZDoomExceptions.h index 45e1ec820..9513cc9b4 100644 --- a/include/ViZDoomExceptions.h +++ b/include/ViZDoomExceptions.h @@ -58,15 +58,6 @@ namespace vizdoom{ std::string error; }; - class SignalException : public std::exception { - public: - SignalException(std::string signal): signal(signal){} - ~SignalException() throw(){} - const char* what() const throw(); - private: - std::string signal; - }; - class ViZDoomErrorException : public std::exception { public: ViZDoomErrorException(){} diff --git a/src/lib/ViZDoomController.cpp b/src/lib/ViZDoomController.cpp index 07008f80b..fba598129 100644 --- a/src/lib/ViZDoomController.cpp +++ b/src/lib/ViZDoomController.cpp @@ -157,9 +157,6 @@ namespace vizdoom { this->MQDoom = new MessageQueue(MQ_DOOM_NAME_BASE + this->instanceId); this->MQController = new MessageQueue(MQ_CTR_NAME_BASE + this->instanceId); - // Signal handle thread - this->signalThread = new b::thread(b::bind(&DoomController::handleSignals, this)); - // Doom thread this->doomThread = new b::thread(b::bind(&DoomController::launchDoom, this)); this->doomRunning = true; @@ -221,18 +218,6 @@ namespace vizdoom { this->MQDoom->send(MSG_CODE_CLOSE); } - if (this->signalThread && this->signalThread->joinable()) { - this->ioService->stop(); - - this->signalThread->interrupt(); - this->signalThread->join(); - delete this->signalThread; - this->signalThread = nullptr; - - delete this->ioService; - this->ioService = nullptr; - } - #ifdef OS_POSIX // If the Doom thread is still running, kill the engine process if (this->doomThread && !this->doomThread->joinable()) { @@ -1142,34 +1127,6 @@ namespace vizdoom { } } - - /* Signals */ - /*----------------------------------------------------------------------------------------------------------------*/ - - void DoomController::handleSignals() { - this->ioService = new ba::io_service(); - ba::signal_set signals(*this->ioService, SIGINT, SIGABRT, SIGTERM); - - #if BOOST_VERSION >= 106000 - signals.async_wait(b::bind(signalHandler, b::ref(signals), this, bpl::_1, bpl::_2)); - #else - signals.async_wait(b::bind(signalHandler, b::ref(signals), this, _1, _2)); - #endif - - this->ioService->run(); - } - - void DoomController::signalHandler(ba::signal_set &signal, DoomController *controller, const bs::error_code &error, - int sigNumber) { - controller->intSignal(sigNumber); - } - - void DoomController::intSignal(int sigNumber) { - this->MQDoom->send(MSG_CODE_CLOSE); - this->MQController->send(static_cast(MSG_CODE_SIG + sigNumber)); - } - - /* Flow */ /*----------------------------------------------------------------------------------------------------------------*/ @@ -1191,18 +1148,6 @@ namespace vizdoom { this->close(); throw ViZDoomErrorException(std::string(msg.command)); - case MSG_CODE_SIGINT : - this->close(); - throw SignalException("SIGINT"); - - case MSG_CODE_SIGABRT : - this->close(); - throw SignalException("SIGABRT"); - - case MSG_CODE_SIGTERM : - this->close(); - throw SignalException("SIGTERM"); - default: this->close(); throw MessageQueueException("Unknown message code. Possible ViZDoom version mismatch."); diff --git a/src/lib/ViZDoomController.h b/src/lib/ViZDoomController.h index e847703da..f0140c1bf 100644 --- a/src/lib/ViZDoomController.h +++ b/src/lib/ViZDoomController.h @@ -75,24 +75,15 @@ namespace vizdoom { #define MSG_CODE_COMMAND 24 #define MSG_CODE_CLOSE 25 -#define MSG_CODE_SIG 30 -#define MSG_CODE_SIGINT 30 + SIGINT -#define MSG_CODE_SIGABRT 30 + SIGABRT -#define MSG_CODE_SIGTERM 30 + SIGTERM - /* OSes */ #ifdef __linux__ #define OS_LINUX #define OS_POSIX - #include - #include #elif _WIN32 #define OS_WIN #elif __APPLE__ #define OS_OSX #define OS_POSIX - #include - #include #endif class DoomController { @@ -322,16 +313,6 @@ namespace vizdoom { /* Threads */ /*------------------------------------------------------------------------------------------------------------*/ - ba::io_service *ioService; - b::thread *signalThread; - - void handleSignals(); - - static void signalHandler(ba::signal_set &signal, DoomController *controller, - const bs::error_code &error, int sigNumber); - - void intSignal(int sigNumber); - b::thread *doomThread; #ifdef OS_POSIX diff --git a/src/lib_python/ViZDoomPythonModule.cpp b/src/lib_python/ViZDoomPythonModule.cpp index 8d763a853..af8318c3f 100644 --- a/src/lib_python/ViZDoomPythonModule.cpp +++ b/src/lib_python/ViZDoomPythonModule.cpp @@ -59,7 +59,6 @@ PYBIND11_MODULE(vizdoom, vz){ EXCEPTION_TO_PYT(FileDoesNotExistException) EXCEPTION_TO_PYT(MessageQueueException) EXCEPTION_TO_PYT(SharedMemoryException) - EXCEPTION_TO_PYT(SignalException) EXCEPTION_TO_PYT(ViZDoomIsNotRunningException) EXCEPTION_TO_PYT(ViZDoomErrorException) EXCEPTION_TO_PYT(ViZDoomUnexpectedExitException)