mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
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:
parent
fc32793cc6
commit
a854a6e04a
15 changed files with 6 additions and 206 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue