changed to smart ptrs and trying to fix event_handler_tests
This commit is contained in:
@@ -26,12 +26,12 @@ EventNotifier::EventNotifier() :
|
||||
|
||||
EventNotifier::~EventNotifier()
|
||||
{
|
||||
is_running = false;
|
||||
this->is_running = false;
|
||||
|
||||
Event end_event(0, 0, "END");
|
||||
event_queue->push(end_event);
|
||||
this->event_queue->push(end_event);
|
||||
|
||||
notify_thread.join();
|
||||
this->notify_thread.join();
|
||||
|
||||
delete this->event_queue;
|
||||
}
|
||||
@@ -39,25 +39,25 @@ EventNotifier::~EventNotifier()
|
||||
void EventNotifier::register_event_handler(IEventHandler* handler)
|
||||
{
|
||||
std::lock_guard<std::mutex> event_handler_guard(event_handler_mutex);
|
||||
event_handlers.insert(handler);
|
||||
this->event_handlers.insert(handler);
|
||||
}
|
||||
|
||||
void EventNotifier::unregister_event_handler(IEventHandler* handler)
|
||||
{
|
||||
std::lock_guard<std::mutex> event_handler_guard(event_handler_mutex);
|
||||
event_handlers.erase(handler);
|
||||
this->event_handlers.erase(handler);
|
||||
}
|
||||
|
||||
void EventNotifier::distribute_event(Event& event)
|
||||
{
|
||||
event_queue->push(event);
|
||||
this->event_queue->push(event);
|
||||
}
|
||||
|
||||
void EventNotifier::notify()
|
||||
{
|
||||
while(is_running)
|
||||
while(this->is_running)
|
||||
{
|
||||
Event event = event_queue->pop();
|
||||
Event event = this->event_queue->pop();
|
||||
|
||||
// TODO schoener machen
|
||||
if(event.name == "END")
|
||||
@@ -66,8 +66,8 @@ void EventNotifier::notify()
|
||||
}
|
||||
|
||||
// getting a guard and calling all registered handlers
|
||||
std::lock_guard event_handler_guard(event_handler_mutex);
|
||||
for(auto handler : event_handlers)
|
||||
std::lock_guard event_handler_guard(this->event_handler_mutex);
|
||||
for(auto handler : this->event_handlers)
|
||||
{
|
||||
boost::thread handler_caller(boost::bind(&IEventHandler::handle, handler, event));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user