Reinstated the original mechanism for OperationThread::cancel() that co-operatively releases blocks/barriers to make sure the thread is able to exit correctly.

git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14468 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield
2014-11-05 13:38:50 +00:00
parent 7a33cc00cd
commit 9cda04e51f

View File

@@ -340,6 +340,30 @@ int OperationThread::cancel()
}
// then wait for the the thread to stop running.
while(isRunning())
{
#if 1
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_threadMutex);
if (_operationQueue.valid())
{
_operationQueue->releaseOperationsBlock();
// _operationQueue->releaseAllOperations();
}
if (_currentOperation.valid()) _currentOperation->release();
}
#endif
// commenting out debug info as it was cashing crash on exit, presumable
// due to OSG_NOTIFY or std::cout destructing earlier than this destructor.
OSG_DEBUG<<" Waiting for OperationThread to cancel "<<this<<std::endl;
OpenThreads::Thread::YieldCurrentThread();
}
// use join to appease valgrind as the above loop won't exit till the thread stops running
// but valgrind doesn't reconginze this and assumes the thread is still running
join();
}