diff --git a/src/osg/GraphicsThread.cpp b/src/osg/GraphicsThread.cpp index 88bb4f49d..1748ba269 100644 --- a/src/osg/GraphicsThread.cpp +++ b/src/osg/GraphicsThread.cpp @@ -39,6 +39,88 @@ struct BlockOperation : public Operation, public Block } }; +///////////////////////////////////////////////////////////////////////////// +// +// OperationsQueue +// + +OperationQueue::OperationQueue() +{ +} + +OperationQueue::~OperationQueue() +{ +} + +void OperationQueue::add(Operation* operation) +{ + osg::notify(osg::INFO)<<"Doing add"< lock(_operationsMutex); + + // add the operation to the end of the list + _operations.push_back(operation); + + _operationsBlock->set(true); + } +} + +void OperationQueue::remove(Operation* operation) +{ + osg::notify(osg::INFO)<<"Doing remove operation"< lock(_operationsMutex); + + for(Operations::iterator itr = _operations.begin(); + itr!=_operations.end();) + { + if ((*itr)==operation) itr = _operations.erase(itr); + else ++itr; + } +} + +void OperationQueue::remove(const std::string& name) +{ + osg::notify(osg::INFO)<<"Doing remove named operation"< lock(_operationsMutex); + + // find the remove all operations with specificed name + for(Operations::iterator itr = _operations.begin(); + itr!=_operations.end();) + { + if ((*itr)->getName()==name) itr = _operations.erase(itr); + else ++itr; + } + + if (_operations.empty()) + { + _operationsBlock->set(false); + } +} + +void OperationQueue::removeAllOperations() +{ + osg::notify(osg::INFO)<<"Doing remove all operations"< lock(_operationsMutex); + _operations.clear(); + + if (_operations.empty()) + { + _operationsBlock->set(false); + } +} + + +///////////////////////////////////////////////////////////////////////////// +// +// OperationsThread +// OperationsThread::OperationsThread(): _parent(0), @@ -92,7 +174,7 @@ int OperationsThread::cancel() osg::notify(osg::INFO)<<" Doing cancel "< lock(_operationsMutex); - for(OperationQueue::iterator itr = _operations.begin(); + for(Operations::iterator itr = _operations.begin(); itr != _operations.end(); ++itr) { @@ -168,7 +250,7 @@ void OperationsThread::remove(Operation* operation) // aquire the lock on the operations queue to prevent anyone else for modifying it at the same time OpenThreads::ScopedLock lock(_operationsMutex); - for(OperationQueue::iterator itr = _operations.begin(); + for(Operations::iterator itr = _operations.begin(); itr!=_operations.end();) { if ((*itr)==operation) itr = _operations.erase(itr); @@ -184,7 +266,7 @@ void OperationsThread::remove(const std::string& name) OpenThreads::ScopedLock lock(_operationsMutex); // find the remove all operations with specificed name - for(OperationQueue::iterator itr = _operations.begin(); + for(Operations::iterator itr = _operations.begin(); itr!=_operations.end();) { if ((*itr)->getName()==name) itr = _operations.erase(itr); @@ -224,7 +306,7 @@ void OperationsThread::run() bool firstTime = true; - OperationQueue::iterator itr = _operations.begin(); + Operations::iterator itr = _operations.begin(); do {