2016-02-09 14:30:53 +00:00
|
|
|
#include "unrefqueue.hpp"
|
|
|
|
|
2016-02-09 15:09:55 +00:00
|
|
|
#include <deque>
|
|
|
|
|
2016-02-09 14:30:53 +00:00
|
|
|
//#include <osg/Timer>
|
|
|
|
//#include <iostream>
|
|
|
|
|
|
|
|
#include <components/sceneutil/workqueue.hpp>
|
|
|
|
|
|
|
|
namespace SceneUtil
|
|
|
|
{
|
|
|
|
|
|
|
|
class UnrefWorkItem : public SceneUtil::WorkItem
|
|
|
|
{
|
|
|
|
public:
|
2017-02-04 01:24:42 +00:00
|
|
|
std::deque<osg::ref_ptr<const osg::Referenced> > mObjects;
|
2016-02-09 14:30:53 +00:00
|
|
|
|
|
|
|
virtual void doWork()
|
|
|
|
{
|
|
|
|
//osg::Timer timer;
|
|
|
|
//size_t objcount = mObjects.size();
|
|
|
|
mObjects.clear();
|
|
|
|
//std::cout << "cleared " << objcount << " objects in " << timer.time_m() << std::endl;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
UnrefQueue::UnrefQueue()
|
|
|
|
{
|
|
|
|
mWorkItem = new UnrefWorkItem;
|
|
|
|
}
|
|
|
|
|
2017-02-04 01:24:42 +00:00
|
|
|
void UnrefQueue::push(const osg::Referenced *obj)
|
2016-02-09 14:30:53 +00:00
|
|
|
{
|
|
|
|
mWorkItem->mObjects.push_back(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
void UnrefQueue::flush(SceneUtil::WorkQueue *workQueue)
|
|
|
|
{
|
|
|
|
if (mWorkItem->mObjects.empty())
|
|
|
|
return;
|
|
|
|
|
2016-03-28 22:25:51 +00:00
|
|
|
workQueue->addWorkItem(mWorkItem, true);
|
2016-02-09 14:30:53 +00:00
|
|
|
|
|
|
|
mWorkItem = new UnrefWorkItem;
|
|
|
|
}
|
|
|
|
|
2017-02-22 01:18:18 +00:00
|
|
|
unsigned int UnrefQueue::getNumItems() const
|
|
|
|
{
|
|
|
|
return mWorkItem->mObjects.size();
|
|
|
|
}
|
|
|
|
|
2016-02-09 14:30:53 +00:00
|
|
|
}
|