mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
Add the unref work items to the front of the workqueue (Bug #3273)
Ensures that memory still gets freed even if the workqueue is overloaded.
This commit is contained in:
parent
bc36269617
commit
2f8be401cc
4 changed files with 12 additions and 8 deletions
|
@ -55,7 +55,7 @@ WorkQueue::~WorkQueue()
|
|||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mMutex);
|
||||
while (!mQueue.empty())
|
||||
mQueue.pop();
|
||||
mQueue.pop_back();
|
||||
mIsReleased = true;
|
||||
mCondition.broadcast();
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ WorkQueue::~WorkQueue()
|
|||
}
|
||||
}
|
||||
|
||||
void WorkQueue::addWorkItem(osg::ref_ptr<WorkItem> item)
|
||||
void WorkQueue::addWorkItem(osg::ref_ptr<WorkItem> item, bool front)
|
||||
{
|
||||
if (item->isDone())
|
||||
{
|
||||
|
@ -76,7 +76,10 @@ void WorkQueue::addWorkItem(osg::ref_ptr<WorkItem> item)
|
|||
}
|
||||
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mMutex);
|
||||
mQueue.push(item);
|
||||
if (front)
|
||||
mQueue.push_front(item);
|
||||
else
|
||||
mQueue.push_back(item);
|
||||
mCondition.signal();
|
||||
}
|
||||
|
||||
|
@ -90,7 +93,7 @@ osg::ref_ptr<WorkItem> WorkQueue::removeWorkItem()
|
|||
if (!mQueue.empty())
|
||||
{
|
||||
osg::ref_ptr<WorkItem> item = mQueue.front();
|
||||
mQueue.pop();
|
||||
mQueue.pop_front();
|
||||
return item;
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue