Moved Producer::Block temporarily into osgDB to ensure that osgDB isn't dependent

on Producer.
This commit is contained in:
Robert Osfield
2003-10-12 14:51:54 +00:00
parent 42eb39ef37
commit ea04f48251
2 changed files with 45 additions and 6 deletions

View File

@@ -21,8 +21,7 @@
#include <OpenThreads/Thread>
#include <OpenThreads/Mutex>
#include <Producer/Block>
#include <OpenThreads/Condition>
#include <osgDB/Export>
@@ -31,6 +30,46 @@
namespace osgDB {
class Block: public osg::Referenced {
public:
Block():_released(false) {}
void block()
{
_mut.lock();
if( !_released )
_cond.wait(&_mut);
_mut.unlock();
}
void release()
{
_mut.lock();
_released = true;
_cond.broadcast();
_mut.unlock();
}
void reset()
{
_mut.lock();
_released = false;
_mut.unlock();
}
protected:
~Block()
{
release();
}
private:
OpenThreads::Mutex _mut;
OpenThreads::Condition _cond;
bool _released;
};
/** Database paging class which manages the loading of files in a background thread,
* and syncronizing of loaded models with the main scene graph.*/
class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandler, public OpenThreads::Thread
@@ -151,12 +190,12 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
virtual ~DatabasePager();
osg::ref_ptr<Producer::Block> _frameBlock;
osg::ref_ptr<Block> _frameBlock;
int _frameNumber;
DatabaseRequestList _fileRequestList;
OpenThreads::Mutex _fileRequestListMutex;
osg::ref_ptr<Producer::Block> _fileRequestListEmptyBlock;
osg::ref_ptr<Block> _fileRequestListEmptyBlock;
DatabaseRequestList _dataToCompileList;
OpenThreads::Mutex _dataToCompileListMutex;

View File

@@ -20,8 +20,8 @@ DatabasePager::DatabasePager()
//osg::notify(osg::INFO)<<"Constructing DatabasePager()"<<std::endl;
_frameNumber = 0;
_frameBlock = new Producer::Block;
_fileRequestListEmptyBlock = new Producer::Block;
_frameBlock = new Block;
_fileRequestListEmptyBlock = new Block;
_deleteRemovedSubgraphsInDatabaseThread = true;