From Xin Li, "use std::list::splice to replace std::list::insert and std::list::clear
it may use the constant time to move all the items in the '_eventQueue' to 'events', and reduce the mutex holding time"
This commit is contained in:
@@ -53,8 +53,7 @@ bool EventQueue::takeEvents(Events& events)
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_eventQueueMutex);
|
||||
if (!_eventQueue.empty())
|
||||
{
|
||||
events.insert(events.end(),_eventQueue.begin(),_eventQueue.end());
|
||||
_eventQueue.clear();
|
||||
events.splice(events.end(), _eventQueue);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user