Added protection to the DatabasePager::requestNodeFile()'s call to startThread

to ensure that only one startThread is every issued.
This commit is contained in:
Robert Osfield
2003-10-09 09:48:36 +00:00
parent 1a6dc82d32
commit 3b65b028b2

View File

@@ -5,6 +5,8 @@
#include <osg/Texture>
#include <osg/Notify>
#include <OpenThreads/ScopedLock>
#ifdef WIN32
#include <windows.h>
#else
@@ -111,12 +113,22 @@ void DatabasePager::requestNodeFile(const std::string& fileName,osg::Group* grou
_fileRequestListMutex.unlock();
}
//if (!threadIsRunning())
if (!isRunning())
{
osg::notify(osg::DEBUG_INFO)<<"DatabasePager::startThread()"<<std::endl;
setSchedulePriority(PRIORITY_MIN);
startThread();
static OpenThreads::Mutex s_mutex;
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex);
static bool s_startThreadCalled = false;
if (!s_startThreadCalled)
{
s_startThreadCalled = true;
osg::notify(osg::DEBUG_INFO)<<"DatabasePager::startThread()"<<std::endl;
setSchedulePriority(PRIORITY_MIN);
startThread();
}
}
}