Added support for an update OperationQueue to Viewer and CompositeViewer to allow asyncrnous adding of operations to be added

to the view to be done during syncronous updateTraversal().

This feature can be used for doing things like merging subgraphs that have been loaded
in a background thread.
This commit is contained in:
Robert Osfield
2007-08-11 10:28:14 +00:00
parent 0e475106dc
commit e5a365afee
9 changed files with 348 additions and 3 deletions

View File

@@ -181,6 +181,40 @@ void OperationQueue::removeAllOperations()
}
}
void OperationQueue::runOperations(Object* callingObject)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_operationsMutex);
// reset current operation iterator to begining if at end.
if (_currentOperationIterator==_operations.end()) _currentOperationIterator = _operations.begin();
for(;
_currentOperationIterator != _operations.end();
)
{
ref_ptr<Operation> operation = *_currentOperationIterator;
if (!operation->getKeep())
{
_currentOperationIterator = _operations.erase(_currentOperationIterator);
}
else
{
++_currentOperationIterator;
}
// osg::notify(osg::INFO)<<"Doing op "<<_currentOperation->getName()<<" "<<this<<std::endl;
// call the graphics operation.
(*operation)(callingObject);
}
if (_operations.empty())
{
_operationsBlock->set(false);
}
}
void OperationQueue::releaseOperationsBlock()
{
_operationsBlock->release();