refactor with logging

This commit is contained in:
Jonas Zeunert
2018-05-31 19:23:42 +02:00
parent 0dfe020934
commit 04b540d8b8
5 changed files with 19 additions and 3 deletions

View File

@@ -0,0 +1 @@

View File

@@ -5,6 +5,10 @@
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht * Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
*/ */
#include <boost/thread.hpp>
#include "../utilities/config.h"
#include "EventNotifier.h" #include "EventNotifier.h"
namespace Input namespace Input
@@ -50,8 +54,13 @@ void EventNotifier::notify()
std::lock_guard<std::mutex> event_handler_guard(event_handler_mutex); std::lock_guard<std::mutex> event_handler_guard(event_handler_mutex);
for(auto handler : event_handler) for(auto handler : event_handler)
{ {
// todo timeout! boost::thread handler_caller(handler, &EventHandler::handle, event);
handler->handle(event);
if(!handler_caller.timed_join(boost::posix_time::milliseconds(HANDLER_TIMEOUT)))
{
CLOG(WARNING, INPUT_LOGGER) << "Handler " << typeid(handler).name() << " didn't finish in "
<< HANDLER_TIMEOUT << " milliseconds. Aborting Execution!";
}
} }
} }
} }

View File

@@ -16,6 +16,8 @@
#include "Event.hpp" #include "Event.hpp"
#include "EventHandler.hpp" #include "EventHandler.hpp"
#define HANDLER_TIMEOUT 2000
namespace Input namespace Input
{ {

View File

@@ -12,7 +12,7 @@
#include <exception> #include <exception>
#define MATRIX_SIZE 8 #define INPUT_MATRIX_SIZE 8
class InputGPIOInterface : GPIOInterface class InputGPIOInterface : GPIOInterface
{ {

View File

@@ -5,4 +5,8 @@
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht * Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
*/ */
#include "../lib/easylogging/easylogging++.h"
#define INPUT_LOGGER "input_logger" #define INPUT_LOGGER "input_logger"
#define INPUT_MATRIX_SIZE 8