fixed some testing bugs

This commit is contained in:
Jonas Zeunert
2018-07-10 23:49:35 +02:00
parent 14b5118038
commit cfccb67561
6 changed files with 22 additions and 12 deletions

View File

@@ -25,9 +25,9 @@ Detector::Detector(IInputGPIOInterface* input_gpio_interface, std::map<char, Eve
Detector::~Detector()
{
is_running = false;
this->is_running = false;
detect_thread.join();
this->detect_thread.join();
delete this->input_gpio_interface;
this->input_gpio_interface = NULL;
@@ -39,7 +39,7 @@ Detector::~Detector()
// Cycles over all s and enqueues an event if detected.
void Detector::detect()
{
while(is_running)
while(this->is_running)
{
char address;
if(this->check_inputs(address))

View File

@@ -26,7 +26,8 @@ EventNotifier::~EventNotifier()
{
is_running = false;
event_queue.release();
Event end_event(0, 0, "END");
event_queue.push(end_event);
notify_thread.join();
}
@@ -54,6 +55,12 @@ void EventNotifier::notify()
{
Event event = event_queue.pop();
// TODO schoener machen
if(event.name == "END")
{
return;
}
// getting a guard and calling all registered handlers
std::lock_guard<std::mutex> event_handler_guard(event_handler_mutex);
for(auto handler : event_handler)

View File

@@ -32,7 +32,9 @@ public:
T pop()
{
std::unique_lock<std::mutex> lock(this->d_mutex);
// TODO die queue funzt net weil wir nich pushen koennen wenn wir im pop warten
// TODO denk ma ueber future nach
std::unique_lock<std::mutex> lock(this->d_mutex);
this->d_condition.wait(lock, [=]{ return !this->p_queue.empty(); });
T rc = *this->p_queue.end();
this->p_queue.pop();