[osg-users] [build] ViewerBase::setThreadingModel() not working

Guy Volckaert guy.volckaert at meggitt.com
Thu Jul 12 08:22:14 PDT 2018


Hi,

When I try to cycle through the threading models by pressing the 'm' key (when the ThreadingHandler is registered) the stats would indicates the correct threading model, but the engine would remain in SingleThreaded. So I started investigating the issue and I noticed that, with OSG v3.6.2, the ViewerBase::setThreadingModel() changed compared with v3.4.0. Below is a snipit of function:
 

Code:

void ViewerBase::setThreadingModel(ThreadingModel threadingModel)
{
    if (_threadingModel == threadingModel) return;

    bool needSetUpThreading = _threadsRunning

    if (_threadsRunning) stopThreading();

    _threadingModel = threadingModel;

    if (needSetUpThreading) setUpThreading();
}





If the current threading model is SingleThreaded then _threadsRunning will be false which means that needSetUpThreading will also be false. Therefore, setUpThreading() will never be called if we are in SingleThreaded. 

Rolling back the function to v3.4.0 seems to resolve the problem, but I'm not sure if that will cause other issues. There's obviously a reason why it was changed. I would like someone with more experience that I to way in. Below is a snipit of the rolled-back function. 
  

Code:

void ViewerBase::setThreadingModel(ThreadingModel threadingModel)
{
    if (_threadingModel == threadingModel) return;

    if (_threadsRunning) stopThreading();

    _threadingModel = threadingModel;

    if (isRealized() && _threadingModel!=SingleThreaded) startThreading();
}




Regards,

Guy

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74324#74324







More information about the osg-users mailing list