fixing compile errors
This commit is contained in:
@@ -23,7 +23,6 @@ Detector::Detector(std::map<std::string, char> input_config, std::map<char, Inpu
|
||||
notify_thread = std::thread(&Detector::notify_handlers, this);
|
||||
}
|
||||
|
||||
|
||||
Detector::~Detector()
|
||||
{
|
||||
is_running = false;
|
||||
@@ -34,13 +33,13 @@ Detector::~Detector()
|
||||
|
||||
void Detector::register_input_event_handler(InputEventHandler* handler)
|
||||
{
|
||||
std::lock_guard<std::mutex> event_handler_guard(event_handler_mutex);
|
||||
LOCK_EVENT_HANDLER();
|
||||
event_handler.insert(handler);
|
||||
}
|
||||
|
||||
void Detector::unregister_input_event_handler(InputEventHandler* handler)
|
||||
{
|
||||
std::lock_guard<std::mutex> event_handler_guard(event_handler_mutex);
|
||||
LOCK_EVENT_HANDLER();
|
||||
event_handler.erase(handler);
|
||||
}
|
||||
|
||||
@@ -55,10 +54,11 @@ void Detector::notify_handlers()
|
||||
return;
|
||||
}
|
||||
|
||||
InputEvent& event = event_queue.pop();
|
||||
|
||||
std::lock_guard<std::mutex> event_handler_guard(event_handler_mutex);
|
||||
InputEvent event = event_queue.front();
|
||||
event_queue.pop();
|
||||
|
||||
// getting a guard and calling all registered handlers
|
||||
LOCK_EVENT_HANDLER();
|
||||
for(auto* handler : event_handler)
|
||||
{
|
||||
handler->handle(event);
|
||||
@@ -66,6 +66,7 @@ void Detector::notify_handlers()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Detector::detect()
|
||||
{
|
||||
while(is_running)
|
||||
@@ -74,7 +75,7 @@ void Detector::detect()
|
||||
if(check_inputs(address))
|
||||
{
|
||||
InputEvent& event = input_events.at(address);
|
||||
event_queue.queue(event);
|
||||
event_queue.emplace(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,11 @@
|
||||
|
||||
#include "InputEvent.h"
|
||||
|
||||
#define LOCK_EVENT_HANDLER() std::lock_guard<std::mutex> event_handler_guard(event_handler_mutex)
|
||||
|
||||
#define SLEEP_DURATION_NANO 900
|
||||
|
||||
|
||||
namespace Input
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user