#include <threads.h>
Inheritance diagram for VIEW::BALLThread:
Public Member Functions | |
void | setMainControl (MainControl *mf) throw () |
void | setComposite (Composite *composite) throw () |
Composite * | getComposite () throw () |
virtual void | run () |
Overloaded from QThread::run(), overload again in derived classes! | |
Protected Member Functions | |
void | sendMessage_ (Message *msg) |
Send a VIEW Message to the main thread. | |
void | updateStructure_ () |
Provokes an update of the Representation's and the Scene with rebuild of the display-lists. | |
void | output_ (const String &string, bool important=false) |
Sends the string as outout to Log.info. | |
void | waitForUpdateOfRepresentations_ () |
Wait until all Representation's are rebuild, by using RepresentationManager::updatePending() and \ RepresentationManager::getUpdateWaitCondition().wait() . | |
Protected Attributes | |
MainControl * | main_control_ |
Composite * | composite_ |
To use multithreading in BALL, there are several problems arising from the fact, that Qt itself is not threadsafe: 1. Prevent any output to Log, stdout or sterr. If a simulation has to print some informations, use the method output_, which will send an Event to the GUI-thread. 2. Dont call any Qt-methods directly. If you need some interaction with the GUI, send a QEvent to the MainControl. 3. Especially dont call the refresh methods for the Scene or GL-methods. Use updateStructure_() instead. 4. Overload the run method to insert the multithreaded code. 5. Call setMainControl() before running the thread 6. Before running a thread, lock the composites with ModularWidget::lockComposites(). 7. After running a thread, unlock them with ModularWidget::unlockComposites(). If you dont pay attention to these rules, dont wonder if BALLView should freeze or crash!
|
Send a VIEW Message to the main thread. Create the message on the heap! |
|
Provokes an update of the Representation's and the Scene with rebuild of the display-lists. This method sends a CompositeMessage with a pointer to the Composite and type CHANGED_COMPOSITE. As a result, the method MainControl::updateRepresentationsOf(..) will be called. |
|
Wait until all Representation's are rebuild, by using RepresentationManager::updatePending() and \ RepresentationManager::getUpdateWaitCondition().wait() .
|