From Tim Moore, "This patch fixes a race condition in Renderer::ThreadSafeQueue that was causing some notifications of available SceneView objects to be missed. I saw a very noticeable performance problem (60 fps -> 8 fps) in DrawThreadPerContext mode in an osgEarth application before this patch. I had high hopes that this change might fix the much-discussed multiple GPU problem; no such luck, but I think the root cause of that is probably a similar threading issue."
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#ifndef OSGVIEWER_RENDERER
|
||||
#define OSGVIEWER_RENDERER 1
|
||||
|
||||
#include <OpenThreads/Condition>
|
||||
#include <osg/Timer>
|
||||
#include <osgDB/DatabasePager>
|
||||
#include <osgUtil/SceneView>
|
||||
@@ -89,20 +90,21 @@ class OSGVIEWER_EXPORT Renderer : public osg::GraphicsOperation
|
||||
struct OSGVIEWER_EXPORT ThreadSafeQueue
|
||||
{
|
||||
OpenThreads::Mutex _mutex;
|
||||
OpenThreads::Block _block;
|
||||
OpenThreads::Condition _cond;
|
||||
typedef std::list<osgUtil::SceneView*> SceneViewList;
|
||||
SceneViewList _queue;
|
||||
bool _isReleased;
|
||||
|
||||
ThreadSafeQueue();
|
||||
~ThreadSafeQueue();
|
||||
|
||||
void release()
|
||||
{
|
||||
_block.release();
|
||||
}
|
||||
|
||||
|
||||
/** Release any thread waiting on the queue, even if the queue is empty. */
|
||||
void release();
|
||||
|
||||
/** Take a SceneView from the queue. Can return 0 if release() is called when the queue is empty. */
|
||||
osgUtil::SceneView* takeFront();
|
||||
|
||||
|
||||
/** Add a SceneView object to the back of the queue. */
|
||||
void add(osgUtil::SceneView* sv);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user