Where am I

24.3. Scenarios for Using Multiple Threads

There are two general scenarios for using multiple threads with Open Inventor:

  • Worker threads

  • Render threads

A worker thread is created to perform an asynchronous task in parallel with the application’s main thread. For example, a worker thread might be created to load a large scene graph from disk. The application can continue to respond to the user’s actions while the file is loading. When the file is loaded, the worker thread calls the viewer’s setSceneGraph() method. A more complex example would be a worker thread that receives or computes new data and asynchronously modifies the scene graph. In both cases, modifying the scene graph while the main thread is doing a traversal, for example rendering, could cause the application to crash.

So the critical issue for worker threads is how to safely modify the scene graph from a separate thread. This is accomplished using the methods SoDB::writelock() and SoDB::writeunlock() as described in Section 24.4, “Modifying the Scene Graph”.

Render threads are used for multi-pipe rendering. Although one thread can render to multiple pipes (sequentially), it is more efficient to render to each pipe with a separate thread. All the render threads traverse the scene graph simultaneously so that rendering can occur in parallel. So the critical issue for render threads is how to ensure that multiple threads can safely traverse the same scene graph, even the same node, simultaneously. For the standard Open Inventor nodes this is handled automatically. An application using custom nodes or SoCallback SoCallback SoCallback nodes may need to be modified as described in Section 24.8, “Custom Nodes Introduction”. Open Inventor is “multi-pipe capable” without any additional software, but it is convenient to delegate creation and management of the render threads to add-on software such as the ScaleViz extension from FEI, CAVELib from VRCO, and others. Examples of using Open Inventor with these products can be found in the Open Inventor SDK installation as follows:

  • ScaleViz extension: $OIVHOME/src/ScaleViz/examples

  • CAVELib: $OIVHOME/src/Inventor/contrib/ImmersiveVR/CAVELib

  • Multipipe SDK: $OIVHOME/src/Inventor/contrib/ImmersiveVR/MultipipeSDK

  • VRJuggler: $OIVHOME/src/Inventor/contrib/ImmersiveVR/VRJuggler