mirror of
https://github.com/introlab/rtabmap_ros.git
synced 2026-10-04 00:37:46 +08:00
0.12.3: Increased Tango rendering performance, modified all handleEvent() with new interface (now returning bool)
This commit is contained in:
@@ -147,10 +147,15 @@ protected:
|
||||
* events are received. If a handling function
|
||||
* takes too much time, the events list can grow
|
||||
* faster than it is emptied. The event can be
|
||||
* modified but must not be deleted.
|
||||
* modified.
|
||||
* @return "true" to notify UEventsManager that this handler took ownership of the
|
||||
* event (meaning it must delete it). The event will
|
||||
* not be dispatched to next handlers.
|
||||
* @return "false" to let event be dispatched to next handlers (default behavior). UEventsManager
|
||||
* will take care of deleting the event.
|
||||
*
|
||||
*/
|
||||
virtual void handleEvent(UEvent * event) = 0;
|
||||
virtual bool handleEvent(UEvent * event) = 0;
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
||||
@@ -175,7 +175,7 @@ private:
|
||||
/*
|
||||
* This method dispatches an event to all handlers.
|
||||
*/
|
||||
virtual void dispatchEvent(UEvent * event, const UEventsSender * sender);
|
||||
virtual bool dispatchEvent(UEvent * event, const UEventsSender * sender);
|
||||
|
||||
/*
|
||||
* This method is used to add an events
|
||||
|
||||
@@ -190,13 +190,15 @@ void UEventsManager::dispatchEvents()
|
||||
// Past events to handlers
|
||||
for(it=eventsBuf.begin(); it!=eventsBuf.end(); ++it)
|
||||
{
|
||||
dispatchEvent(it->first, it->second);
|
||||
delete it->first;
|
||||
if(!dispatchEvent(it->first, it->second))
|
||||
{
|
||||
delete it->first;
|
||||
}
|
||||
}
|
||||
eventsBuf.clear();
|
||||
}
|
||||
|
||||
void UEventsManager::dispatchEvent(UEvent * event, const UEventsSender * sender)
|
||||
bool UEventsManager::dispatchEvent(UEvent * event, const UEventsSender * sender)
|
||||
{
|
||||
std::list<UEventsHandler*> handlers;
|
||||
|
||||
@@ -213,7 +215,9 @@ void UEventsManager::dispatchEvent(UEvent * event, const UEventsSender * sender)
|
||||
handlers = handlers_;
|
||||
}
|
||||
|
||||
for(std::list<UEventsHandler*>::iterator it=handlers.begin(); it!=handlers.end(); ++it)
|
||||
bool handled = false;
|
||||
|
||||
for(std::list<UEventsHandler*>::iterator it=handlers.begin(); it!=handlers.end() && !handled; ++it)
|
||||
{
|
||||
// Check if the handler is still in the
|
||||
// handlers_ list (may be changed if addHandler() or
|
||||
@@ -228,13 +232,14 @@ void UEventsManager::dispatchEvent(UEvent * event, const UEventsSender * sender)
|
||||
{
|
||||
// To be able to add/remove an handler in a handleEvent call (without a deadlock)
|
||||
// @see _addHandler(), _removeHandler()
|
||||
handler->handleEvent(event);
|
||||
handled = handler->handleEvent(event);
|
||||
}
|
||||
|
||||
handlersMutex_.lock();
|
||||
}
|
||||
}
|
||||
handlersMutex_.unlock();
|
||||
return handled;
|
||||
}
|
||||
|
||||
void UEventsManager::_addHandler(UEventsHandler* handler)
|
||||
@@ -309,8 +314,10 @@ void UEventsManager::_postEvent(UEvent * event, bool async, const UEventsSender
|
||||
}
|
||||
else
|
||||
{
|
||||
dispatchEvent(event, sender);
|
||||
delete event;
|
||||
if(!dispatchEvent(event, sender))
|
||||
{
|
||||
delete event;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user