From 84737941e14adc03efa57d184279b3df1f49405e Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 22 Jan 2004 10:42:32 +0000 Subject: [PATCH] Added controls over the datatbase pager threading priority during and outwith the frame. --- include/osgDB/DatabasePager | 16 ++++++++++++++++ src/osgDB/DatabasePager.cpp | 15 +++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/include/osgDB/DatabasePager b/include/osgDB/DatabasePager index 1971523b2..14f244848 100644 --- a/include/osgDB/DatabasePager +++ b/include/osgDB/DatabasePager @@ -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 _frameBlock; int _frameNumber; + ThreadPriority _threadPriorityDuringFrame; + ThreadPriority _threadPriorityOutwithFrame; + DatabaseRequestList _fileRequestList; OpenThreads::Mutex _fileRequestListMutex; osg::ref_ptr _fileRequestListEmptyBlock; diff --git a/src/osgDB/DatabasePager.cpp b/src/osgDB/DatabasePager.cpp index 5d7683d79..d2dbd5a6b 100644 --- a/src/osgDB/DatabasePager.cpp +++ b/src/osgDB/DatabasePager.cpp @@ -19,11 +19,14 @@ DatabasePager::DatabasePager() { //osg::notify(osg::INFO)<<"Constructing DatabasePager()"<>>>>>>>>>>>>>>>"<reset(); + + if (_threadPriorityDuringFrame!=getSchedulePriority()) + setSchedulePriority(_threadPriorityDuringFrame); + } void DatabasePager::signalEndFrame() { //osg::notify(osg::INFO) << "signalEndFrame <<<<<<<<<<<<<<<<<<<< "<release(); + + if (_threadPriorityOutwithFrame!=getSchedulePriority()) + setSchedulePriority(_threadPriorityOutwithFrame); + } class FindCompileableGLObjectsVisitor : public osg::NodeVisitor