From 9cda04e51f0d34d333d4d93313a6aaca7a829f30 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 5 Nov 2014 13:38:50 +0000 Subject: [PATCH] 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 --- src/osg/OperationThread.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/osg/OperationThread.cpp b/src/osg/OperationThread.cpp index 556c8346c..43f252a1b 100644 --- a/src/osg/OperationThread.cpp +++ b/src/osg/OperationThread.cpp @@ -340,6 +340,30 @@ int OperationThread::cancel() } // then wait for the the thread to stop running. + while(isRunning()) + { + +#if 1 + { + OpenThreads::ScopedLock 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 "<