removes UnrefQueue (#3181)

Currently, we use an `UnrefQueue` which supposedly aims to transfer destruction costs to another thread. The implications of this unusual pattern can not be well understood because some allocators might free resources more efficiently if they are freed by the same thread that allocated them. In addition, `UnrefQueue` complicates the validation of thread safety in our engine. Lastly, our current usage of `UnrefQueue` triggers `ref()`, `unref()` atomic operations as objects are passed into the queue. These operations could be more expensive than the actual destruction.

With this PR we thus remove `UnrefQueue`. We can expect these changes to have a minor impact at most because we free most resources elsewhere in `ResourceSystem::updateCache`.
This commit is contained in:
Bo Svensson 2021-10-20 21:02:15 +00:00 committed by GitHub
parent fc32793cc6
commit a854a6e04a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 6 additions and 206 deletions

View file

@ -1,39 +0,0 @@
#include "unrefqueue.hpp"
//#include <osg/Timer>
//#include <components/debug/debuglog.hpp>
namespace SceneUtil
{
void UnrefWorkItem::doWork()
{
mObjects.clear();
}
UnrefQueue::UnrefQueue()
{
mWorkItem = new UnrefWorkItem;
}
void UnrefQueue::push(const osg::Referenced *obj)
{
mWorkItem->mObjects.emplace_back(obj);
}
void UnrefQueue::flush(SceneUtil::WorkQueue *workQueue)
{
if (mWorkItem->mObjects.empty())
return;
workQueue->addWorkItem(mWorkItem, true);
mWorkItem = new UnrefWorkItem;
}
unsigned int UnrefQueue::getNumItems() const
{
return mWorkItem->mObjects.size();
}
}