[vtkusers] Multi threading question

Andi2008 mail-andi at web.de
Fri Feb 27 02:50:50 EST 2009


Hi,

if you syncronize the access to vtk by a global mutex or syncronize the
Render() methode in the RenderWindow it will work but in this case i think
you dont need a multitheading architecture anymore. Maybe you can find out
which parts of vtk are thread- unsafe and only syncronize them. 
 
I have the same problem because i work with RenderWindows in different
threads. I found out, that there are some singleton classes in vtk which are
not threadsafe. Those are vtkFreeTypeUtilities and the Register() methode of
vtkFilteringInformationKeyManager and vtkCommonInformationKeyManager. When i
syncronize the access to this classes vtk works threadsafe in my programm.
You loose performance with this but it is not that much than synronizing the
access to vtk globally. 

I hope it helps
Andi



Matthias Riechmann wrote:
> 
> This might work - as long as there is no not-thread-safe code between in 
> the procedures that are responsible for sending the StartEvent. And I'm 
> not sure whether VTK likes events being stalled by mutexes, I'm not deep 
> enough in VTK's event system. Are there any developers nearby? ;-)
> 
> 
> Matthias
> 
> 
> 
> 
> Clinton Stimpson schrieb:
>> 
>> How about locking/unlocking when you get the 
>> vtkCommand::StartEvent/vtkCommand::EndEvent from the vtkRenderWindow?
>> Then the locking is automatic no matter where Render() was called from.
>> 
>> Clint
>> 
>> Matthias Riechmann wrote:
>>> I have a similar question: When triggering all rendering by yourself 
>>> it is easy to protect VTK from concurrent access by using a mutex. But 
>>> how can I do that when using a QVtkWidget? In this case the rendering 
>>> might be triggered at any time from the GUI. Is there a way to do a 
>>> synchronisation from a application programmer's view in this scenario?
>>>
>>>
>>> Matthias
>>>
>>>
>>>
>>>
>>> David E DeMarle schrieb:
>>>> What you are doing is correct. VTK is not thread safe, so in general
>>>> you have to protect against concurrent access manually as you have
>>>> done.
>>>>
>>>> On Mon, Feb 23, 2009 at 10:51 PM, Anton Deguet <anton.deguet at jhu.edu> 
>>>> wrote:
>>>>> Hello,
>>>>>
>>>>> I have an application with one renderer and multiple actors.  Each 
>>>>> actor (assembly) is controlled by a different thread and all use a 
>>>>> single renderer (running in its own thread).  As a temporary 
>>>>> solution, I use an application wide mutex lock/unlock for any access 
>>>>> to VTK to avoid rendering while a thread is modifying the scene via 
>>>>> its actor (threads can modify anything; position, size, visibility, 
>>>>> opacity, texture, ... and other non atomic operations).  It somewhat 
>>>>> works but I am afraid one programmer might forget to lock/unlock the 
>>>>> scene before modifying its actors and this might be hard to 
>>>>> debug/detect.  I am also slightly concerned by long waiting periods 
>>>>> to lock the mutex as the application is growing.
>>>>>
>>>>> So, does VTK provide something better than what I am using, i.e. is 
>>>>> there any build-in thread safety mechanism that one can use 
>>>>> (multiple buffers, queued commands, ...) that would avoid locks.
>>>>>
>>>>> Thank you,
>>>>>
>>>>> Anton Deguet
>>>>> _______________________________________________
>>>>> Powered by www.kitware.com
>>>>>
>>>>> Visit other Kitware open-source projects at 
>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>
>>>>> Please keep messages on-topic and check the VTK FAQ at: 
>>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>>>
>>>>> Follow this link to subscribe/unsubscribe:
>>>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>>>
>>>>
>>>>
>>>>
>>>
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at 
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the VTK FAQ at: 
>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>   
>> 
>> 
> 
> -- 
> Dipl.-Inform. Matthias Riechmann
> Institut für Prozessrechentechnik, Automation und Robotik
> Medizin-Gruppe
> Universität Karlsruhe (TH)
> Gebäude 40.28, Zimmer 103
> Engler-Bunte-Ring 8
> 76131 Karlsruhe
> 
> Fon: +49 (721) 608-4049
> Fax: +49 (721) 608-7141
> 
> Web: http://wwwipr.ira.uka.de/~richmann
> 
> begin:vcard
> fn:Matthias Riechmann
> n:Riechmann;Matthias
> org;quoted-printable;quoted-printable:Universit=C3=A4t Karlsruhe
> (TH);Institut f=C3=BCr Prozessrechentechnik, Automation und Robotik
> adr;quoted-printable;quoted-printable:Geb=C3=A4ude 40.28, Zimmer
> 103;;Engler-Bunte-Ring 8;Karlsruhe;Baden-W=C3=BCrttemberg;76131;germany
> email;internet:riechmann at ira.uka.de
> tel;work:+49 (721) 608-4049
> tel;fax:+49 (721) 608-7141
> url:Web: http://wwwipr.ira.uka.de/~richmann
> version:2.1
> end:vcard
> 
> 
>  
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 
> 

-- 
View this message in context: http://www.nabble.com/Multi-threading-question-tp22175349p22240997.html
Sent from the VTK - Users mailing list archive at Nabble.com.




More information about the vtkusers mailing list