1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-19 20:23:54 +00:00

Avoid copying osg::ref_ptr when adding or removing item from work queue

Copy constructor does refcounting, and move constructor doesn't.
This commit is contained in:
elsid 2021-07-10 12:11:48 +02:00
parent b8fcd6d3ba
commit eece47f70e
No known key found for this signature in database
GPG key ID: B845CB9FEE18AB40
2 changed files with 4 additions and 4 deletions

View file

@ -492,7 +492,7 @@ namespace MWRender
workItem->mTextures.emplace_back("textures/_land_default.dds"); workItem->mTextures.emplace_back("textures/_land_default.dds");
mWorkQueue->addWorkItem(workItem); mWorkQueue->addWorkItem(std::move(workItem));
} }
double RenderingManager::getReferenceTime() const double RenderingManager::getReferenceTime() const

View file

@ -74,9 +74,9 @@ void WorkQueue::addWorkItem(osg::ref_ptr<WorkItem> item, bool front)
std::unique_lock<std::mutex> lock(mMutex); std::unique_lock<std::mutex> lock(mMutex);
if (front) if (front)
mQueue.push_front(item); mQueue.push_front(std::move(item));
else else
mQueue.push_back(item); mQueue.push_back(std::move(item));
mCondition.notify_one(); mCondition.notify_one();
} }
@ -89,7 +89,7 @@ osg::ref_ptr<WorkItem> WorkQueue::removeWorkItem()
} }
if (!mQueue.empty()) if (!mQueue.empty())
{ {
osg::ref_ptr<WorkItem> item = mQueue.front(); osg::ref_ptr<WorkItem> item = std::move(mQueue.front());
mQueue.pop_front(); mQueue.pop_front();
return item; return item;
} }