Added controls over the datatbase pager threading priority during and outwith the frame.

This commit is contained in:
Robert Osfield
2004-01-22 10:42:32 +00:00
parent b604d22982
commit 84737941e1
2 changed files with 29 additions and 2 deletions

View File

@@ -98,6 +98,19 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
/** Get the whether UseFrameBlock is on or off.*/
bool getUseFrameBlock() const { return _useFrameBlock; }
/** Set the priority of the database pager thread during the frame (i.e. while cull and draw are running.)*/
void setThreadPriorityDuringFrame(ThreadPriority duringFrame) { _threadPriorityDuringFrame = duringFrame; }
/** Get the priority of the database pager thread during the frame*/
ThreadPriority getThreadPriorityDuringFrame() const { return _threadPriorityDuringFrame; }
/** Set the priority of the database pager thread when the frame is not being exectuted (i.e. before or after cull and draw have run.)*/
void setThreadPriorityOutwithFrame(ThreadPriority outwithFrame) { _threadPriorityOutwithFrame = outwithFrame; }
/** Get the priority of the database pager thread when the frame is not being exectuted.*/
ThreadPriority getThreadPriorityOutwithFrame() const { return _threadPriorityOutwithFrame; }
/** Signal the database thread that the update, cull and draw has begun for a new frame.
* Note, this is called by the application so that the database pager can go to sleep while the CPU is busy on the main rendering threads. */
@@ -214,6 +227,9 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
osg::ref_ptr<Block> _frameBlock;
int _frameNumber;
ThreadPriority _threadPriorityDuringFrame;
ThreadPriority _threadPriorityOutwithFrame;
DatabaseRequestList _fileRequestList;
OpenThreads::Mutex _fileRequestListMutex;
osg::ref_ptr<Block> _fileRequestListEmptyBlock;

View File

@@ -19,11 +19,14 @@ DatabasePager::DatabasePager()
{
//osg::notify(osg::INFO)<<"Constructing DatabasePager()"<<std::endl;
_useFrameBlock = false;
_useFrameBlock = false;
_frameNumber = 0;
_frameBlock = new Block;
_fileRequestListEmptyBlock = new Block;
_threadPriorityDuringFrame = PRIORITY_MIN;
_threadPriorityOutwithFrame = PRIORITY_NOMINAL;
_deleteRemovedSubgraphsInDatabaseThread = true;
_expiryDelay = 1.0;
@@ -166,7 +169,7 @@ void DatabasePager::requestNodeFile(const std::string& fileName,osg::Group* grou
{
s_startThreadCalled = true;
osg::notify(osg::DEBUG_INFO)<<"DatabasePager::startThread()"<<std::endl;
setSchedulePriority(PRIORITY_MIN);
setSchedulePriority(_threadPriorityDuringFrame);
startThread();
}
@@ -182,12 +185,20 @@ void DatabasePager::signalBeginFrame(const osg::FrameStamp* framestamp)
} //else osg::notify(osg::INFO) << "signalBeginFrame >>>>>>>>>>>>>>>>"<<std::endl;
_frameBlock->reset();
if (_threadPriorityDuringFrame!=getSchedulePriority())
setSchedulePriority(_threadPriorityDuringFrame);
}
void DatabasePager::signalEndFrame()
{
//osg::notify(osg::INFO) << "signalEndFrame <<<<<<<<<<<<<<<<<<<< "<<std::endl;
_frameBlock->release();
if (_threadPriorityOutwithFrame!=getSchedulePriority())
setSchedulePriority(_threadPriorityOutwithFrame);
}
class FindCompileableGLObjectsVisitor : public osg::NodeVisitor