VR-Forces 4.1.1 Class Documentation
2.5 - Threading in the GUI API

Table of Contents

The VR-Forces GUI is a multithreaded application.

Therefore, for thread safety reasons, some functions cannot be called from all locations in the code. It is important to be aware of what thread is running particular parts of the GUI that you are customizing, and to not make calls to parts of the API that are managed by another thread.

The important threads of execution in the VR-Forces GUI are:

Generally, the API attempts to prevent developers from accessing parts of the API that are unsafe, however that protection cannot be guaranteed by the API. There are a number of classes that are designed to pass data and events between the threads.

2.5.1 Main Thread

The Main Thread is the thread of execution that runs the Qt main window, takes user input, draws the UI on the screen, runs the makVrv::DtDe class, and runs the OpenGL rendering engine. Most developer code in VR-Forces will be plugins that operate in the main thread. All classes that are accessed using the ClassName::instance(DtDe&) pattern are classes that are owned in the main thread, and can safely be accessed from the main thread.

2.5.2 Driver Thread

The Driver Thread is primarily involved with network communication and with all the communication with the VR-Forces simulation engine. This thread has ownership of the DtExerciseConnection instance that is being used, as well as the DtVrfRemoteController class. All processing of network messages is done by this thread, and relevent data needed in the rest of the application is passed though a threadsafe API to the main thread. Similarly, data in the main thread is passed though threadsafe APIs to the driver thread in order to be sent out on the network.

The DtVrfRemoteController is a class that is often accessed in the GUI API, and to facilitate this access across the thread boundary, there is a main thread class named DtGuiThreadVrfRemoteController which has the same API as DtVrfRemoteController, but passes the calls to the driver thread and executes them there.

[<< Miscellaneous Architectural Topics] [Home] [Top of Page] [Getting the State of a Simulated Object]


Document ID: Generated on Mon Apr 8 19:24:01 EDT 2013 from SVN revision 125877
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)