diff --git a/include/osgDB/DatabasePager b/include/osgDB/DatabasePager index 496e41491..f1c592ea0 100644 --- a/include/osgDB/DatabasePager +++ b/include/osgDB/DatabasePager @@ -21,8 +21,7 @@ #include #include - -#include +#include #include @@ -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 _frameBlock; + osg::ref_ptr _frameBlock; int _frameNumber; DatabaseRequestList _fileRequestList; OpenThreads::Mutex _fileRequestListMutex; - osg::ref_ptr _fileRequestListEmptyBlock; + osg::ref_ptr _fileRequestListEmptyBlock; DatabaseRequestList _dataToCompileList; OpenThreads::Mutex _dataToCompileListMutex; diff --git a/src/osgDB/DatabasePager.cpp b/src/osgDB/DatabasePager.cpp index 4c34f8a7a..c27d2ee35 100644 --- a/src/osgDB/DatabasePager.cpp +++ b/src/osgDB/DatabasePager.cpp @@ -20,8 +20,8 @@ DatabasePager::DatabasePager() //osg::notify(osg::INFO)<<"Constructing DatabasePager()"<