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

Copy constructor does refcounting, and move constructor doesn't.
dont-compose-content
elsid 4 years ago
parent b8fcd6d3ba
commit eece47f70e
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40

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

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

Loading…
Cancel
Save