Re: [ROOT] ROOT/QtROOT within a multithreaded Qt application

From: Joern Adamczewski (J.Adamczewski@gsi.de)
Date: Tue Jan 08 2002 - 10:47:13 MET


Hello Tony, hello rooters

sorry for answering that late, I have been absent for
vacation...

Generally, since ROOT is not threadsafe, you have to acquire
a mutex lock in each Qt-slot or thread that uses ROOT methods
or ROOT object creation. This is independent of the fact if you
use ROOT TThreads or Qt threads.

For the Go4 project, we use a threadsafe version of the
qtroot2.0 interface which works together with the
Go4 threadmanager library, providing proper locking mechanisms.
The published version of qtroot2.0 is meant as a standalone library
without threadmanager library; therefore it is not threadsafe!

However, since you seem to use native qt threads, our threadmanager
would be no solution in your case. But the locking mechanism
of all ROOT methods in your threads should be not that difficult
to implement with a qt mutex, for instance.

Another approach, as you mentioned, would be to let all 
critical operations be done by a timer (within the main thread), 
the way the ROOT TThreadTimer
handles all XActions. Then you must pass the required
information to the timer e.g. by global variables or some static class members
that are set (not instantiated!) by the 
initiating thread and read by the timer.
However, in general I would prefer a mutex lock rather than this.


"Colley, Tony" wrote:
> I have looked at the Qt document "Thread Support in Qt", and at the Threads
> chapter in the ROOT Users Guide, and I have looked at the roottalk messages
> that were found by searching the ROOT website. I have also read through
> http://go4.gsi.de/Threads/tthread.htm (where item 1.2.4 seems to indicate
> that there is no hope). 
Be careful, this latter document is not up to date, especially item 1.2.4,
for the ROOT canvas operations have been improved since we made these
experiences (in July of 1999). Sorry for that!
However, the statements about the root threadsafety in general
(1.2.2.4) are still true, as it was taken into the  
ROOT Users Guide, too.

Best regards,

	Joern

-- 
/////////////////////////////////////////////////////////////////////
// Dr. J"orn Adamczewski                    (J.Adamczewski@gsi.de) // 
// GO4 project team                         Tel: +49-6159-71-2554  //
// Datenverarbeitung & ExperimentElektronik FAX: +49-6159-71-2986  //
// Ges. f. SchwerIonenforschung, Planckstr.1,  D-64291 Darmstadt   //



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:37 MET