Introduced preliminary support for asynchronous file read requests,

ReaderWriter::ReadResult now has a FILE_REQUEST enum.
  ReaderWriter::Options now has a s/getAsynchronousFileReadHint() parameter methods.

  libcurl based plugin now detects enabing of the AsynchronousFileReadHint, but
  as yet does not handle async requests - handling everything syncronously.
  
  DatabasePager now by default will enable AsynchronousFileReadHint for http
  based file requests
This commit is contained in:
Robert Osfield
2008-05-14 17:03:57 +00:00
parent d7c4e6f26e
commit 646fc43747
3 changed files with 53 additions and 9 deletions

View File

@@ -1,5 +1,6 @@
#include <osgDB/DatabasePager>
#include <osgDB/ReadFile>
#include <osgDB/FileNameUtils>
#include <osg/Geode>
#include <osg/Timer>
@@ -419,7 +420,22 @@ void DatabasePager::requestNodeFile(const std::string& fileName,osg::Group* grou
databaseRequest->_timestampLastRequest = timestamp;
databaseRequest->_priorityLastRequest = priority;
databaseRequest->_groupForAddingLoadedSubgraph = group;
databaseRequest->_loadOptions = loadOptions;
if ((Registry::instance()->getOptions()==loadOptions) &&
(loadOptions ? !loadOptions->getAsynchronousFileReadHint() : true) &&
osgDB::containsServerAddress(fileName))
{
// we need to enable asynchronous file reading.
databaseRequest->_loadOptions = loadOptions ?
dynamic_cast<osgDB::ReaderWriter::Options*>(loadOptions->clone(osg::CopyOp::SHALLOW_COPY)) :
new osgDB::ReaderWriter::Options;
databaseRequest->_loadOptions->setAsynchronousFileReadHint(true);
}
else
{
databaseRequest->_loadOptions = loadOptions;
}
_fileRequestList.push_back(databaseRequest);

View File

@@ -316,6 +316,11 @@ class ReaderWriterCURL : public osgDB::ReaderWriter
proxyAddress = std::string(proxyEnvAddress) + ":8080"; //Default
}
bool asyncFileRead = options ? options->getAsynchronousFileReadHint() : false;
osg::notify(osg::INFO)<<"AsynchronousFileReadHint= "<<asyncFileRead<<std::endl;
// if (asyncFileRead) return ReadResult::FILE_REQUESTED;
std::stringstream buffer;
ReadResult curlResult;