BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
BALL::VIEW::BALLThread Class Reference

#include <BALL/VIEW/KERNEL/threads.h>

Inheritance diagram for BALL::VIEW::BALLThread:
QThread BALL::VIEW::CalculateFDPBThread BALL::VIEW::DockingThread BALL::VIEW::GenerateCrystalThread BALL::VIEW::ServerWidget::BALLViewServer BALL::VIEW::SimulationThread BALL::VIEW::UpdateRepresentationThread BALL::VIEW::EnergyMinimizerThread BALL::VIEW::MDSimulationThread

Public Member Functions

 BALLThread ()
 
void setMainControl (MainControl *mf)
 
void setComposite (Composite *composite)
 
CompositegetComposite ()
 
virtual void run ()
 

Protected Member Functions

void sendMessage_ (Message *msg)
 
void updateStructure_ ()
 
void output_ (const String &string, bool important=false)
 Sends the string as outout to Log.info. More...
 
void waitForUpdateOfRepresentations_ ()
 

Protected Attributes

MainControlmain_control_
 
Compositecomposite_
 

Detailed Description

Baseclass for threads in BALL. 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!

Definition at line 70 of file threads.h.

Constructor & Destructor Documentation

BALL::VIEW::BALLThread::BALLThread ( )

Member Function Documentation

Composite* BALL::VIEW::BALLThread::getComposite ( )
inline

Definition at line 85 of file threads.h.

void BALL::VIEW::BALLThread::output_ ( const String string,
bool  important = false 
)
protected

Sends the string as outout to Log.info.

virtual void BALL::VIEW::BALLThread::run ( )
inlinevirtual
void BALL::VIEW::BALLThread::sendMessage_ ( Message msg)
protected

Send a VIEW Message to the main thread. Create the message on the heap!

void BALL::VIEW::BALLThread::setComposite ( Composite composite)
inline

Definition at line 82 of file threads.h.

void BALL::VIEW::BALLThread::setMainControl ( MainControl mf)
inline

Definition at line 79 of file threads.h.

void BALL::VIEW::BALLThread::updateStructure_ ( )
protected

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.

void BALL::VIEW::BALLThread::waitForUpdateOfRepresentations_ ( )
protected

Wait until all Representation's are rebuild, by using RepresentationManager::updatePending() and \ RepresentationManager::getUpdateWaitCondition().wait() .

Member Data Documentation

Composite* BALL::VIEW::BALLThread::composite_
protected

Definition at line 116 of file threads.h.

MainControl* BALL::VIEW::BALLThread::main_control_
protected

Definition at line 115 of file threads.h.