<div dir="ltr">To clarify one thing about garbage collection:<div><br></div><div>As long as 2 threads are not doing garbage collection calls to the same objects, garbage collection is thread safe. This is only an issue if you update the reference of objects that refer to each other in some way from multiple threads. The simplest way of getting rid of this is to not share data objects but use shallow copy to share contents of data objects (arrays). Also, as of VTK 6, data objects are not part of the pipeline's reference loop so it is thread safe to share data objects from multiple threads. Having said that, data objects have bunch of API that is not thread safe so reading data objects from multiple threads is discourage unless you carefully design the code.</div>

<div><br></div><div>Best,</div><div>-berk</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Mar 24, 2014 at 12:26 PM, Richard Whitehead <span dir="ltr"><<a href="mailto:richard.whitehead@vivosight.com" target="_blank">richard.whitehead@vivosight.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Seb,<div>Many thanks for the reply.  I don't think that what you suggest can necessarily be safe, because Update might create temporary objects and that involves the singleton garbage collector.</div>

<div>
<br></div><div>The correct solution is for the garbage collector to be thread-safe. This would only involve some mutex locking, but I don't feel confident to attempt it, even if I had time (I'm now under a lot of time pressure).</div>


<div>Many thanks,</div><div><br></div><div>Richard</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On 24 March 2014 14:56, Sebastien Jourdain <span dir="ltr"><<a href="mailto:sebastien.jourdain@kitware.com" target="_blank">sebastien.jourdain@kitware.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Another approach could be that the creation and the linkage with the UI is going through the single UI thread, but you rely on another thread to execute the actual pipeline by calling Update() on the mapper. Although, do not connect that pipeline yet to the render window until that working thread is done.<div>



<br></div><div>Just my 2 cents,</div><div><br></div><div>Seb</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Mar 24, 2014 at 8:32 AM, Aashish Chaudhary <span dir="ltr"><<a href="mailto:aashish.chaudhary@kitware.com" target="_blank">aashish.chaudhary@kitware.com</a>></span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Hi Richard, </div><div class="gmail_quote"><br></div>


<div class="gmail_quote">
<div>On Mon, Mar 24, 2014 at 10:25 AM, Richard Whitehead <span dir="ltr"><<a href="mailto:richard.whitehead@vivosight.com" target="_blank">richard.whitehead@vivosight.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">David,<div>Unfortunately I am now in a really bad place.  I have some long-winded calculations to do and then visualise, which I want to do in a background thread.  This is for a commercial application and hanging the GUI is completely unacceptable.  I have now invested several man-months into VTK and I have to decide whether to drop it.  I think the only sensible thing I can do is to get rid of VTK from my calculations and only use it for visualisation.</div>




</div></blockquote><div><br></div></div><div>FYI, we have successfully used VTK in a multi-threaded environment for our VisGUI application framework (<a href="http://www.kitware.com/source/home/post/84" target="_blank">http://www.kitware.com/source/home/post/84</a>) specifically dealing with computations. Rendering was done single threaded though. The trick involved writing our own thread safe version of vtkSmartPointer (I believe you are doing something similar).  </div>




<div><br></div><div>- Aashish</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">



<div>
<div dir="ltr">
<div>Many thanks,</div><div>Richard</div><div><br></div></div><div class="gmail_extra"><div><br><br><div class="gmail_quote">On 24 March 2014 12:29, David Cole <span dir="ltr"><<a href="mailto:dlrdave@aol.com" target="_blank">dlrdave@aol.com</a>></span> wrote:<br>





<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">You are definitely not going crazy. The really, really rather foul thing, that frustrates me all the time, is when I must do some VTK operation which takes significant time (on the order of seconds or minutes, rather than the typical fraction of a second) ... and then it makes the GUI completely unresponsive until the operation is done.<br>






<br>
I spend rather a lot of my time making sure that everything I do that's VTK-based is at interactive speeds as much as possible to absolutely minimize the user pain associated with this.<br>
<br>
Pushing long operations completely into a separate non-GUI thread would be absolutely fantastic. I look forward to the day when such a thing becomes possible.<br>
<br>
<br>
:-)<span><font color="#888888"><br>
D<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div></div><div>-- <br><div dir="ltr"><p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif">Richard Whitehead </span><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">–</span></b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif"> Senior Imaging Engineer</span></p>





<p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">Michelson Diagnostics Ltd</span></b></p><p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt">





<b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">M:</span></b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif"> <a href="tel:%2B44%20%280%297905%20955276" value="+447905955276" target="_blank">+44 (0)7905 955276</a>   </span><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">T:</span></b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif"> <a href="tel:%2B44%20%280%2920%208308%201695" value="+442083081695" target="_blank">+44 (0)20 8308 1695</a></span></p>





<p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">E: </span></b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(0,176,240)"><a href="mailto:richard.whitehead@vivosight.com" style="color:rgb(17,85,204)" target="_blank"><span style="color:rgb(0,176,240)">richard.whitehead@vivosight.com</span></a></span><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif">   </span><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">W:</span></b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif"> </span><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(0,176,240)"><a href="http://www.vivosight.com/" style="color:rgb(17,85,204)" target="_blank"><span style="color:rgb(0,176,240)">www.vivosight.com</span></a></span></p>





<p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"><br></p><p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"><a href="http://www.vivosight.com/" target="_blank"><span style="color:windowtext;text-decoration:none"><img src="https://sites.google.com/a/vivosight.com/logo/_/rsrc/1361922206747/home/VivoSight.png" border="0"></span></a></p>





<p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"><br></p><p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"></p><p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt">





<span style="font-size:7.5pt;font-family:Arial,sans-serif;color:gray">Michelson Diagnostics Ltd, 1 Grays Farm Production Village, Grays Farm Road, Orpington, Kent  BR5 3BD, UK</span></p><p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt">





<span style="font-size:7.5pt;font-family:Arial,sans-serif;color:gray">Registered Office: 3 Shearwater, Maidstone, ME16 0DW.     Registered in England No. 5732681</span></p></div>
</div></div>
<br></div><div>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></div></blockquote></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br>| Aashish Chaudhary <br>| R&D Engineer         <br>| Kitware Inc.            <br>| <a href="http://www.kitware.com" target="_blank">www.kitware.com</a>    
</font></span></div></div>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif">Richard Whitehead </span><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">–</span></b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif"> Senior Imaging Engineer</span></p>


<p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">Michelson Diagnostics Ltd</span></b></p><p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt">


<b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">M:</span></b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif"> <a href="tel:%2B44%20%280%297905%20955276" value="+447905955276" target="_blank">+44 (0)7905 955276</a>   </span><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">T:</span></b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif"> <a href="tel:%2B44%20%280%2920%208308%201695" value="+442083081695" target="_blank">+44 (0)20 8308 1695</a></span></p>


<p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">E: </span></b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(0,176,240)"><a href="mailto:richard.whitehead@vivosight.com" style="color:rgb(17,85,204)" target="_blank"><span style="color:rgb(0,176,240)">richard.whitehead@vivosight.com</span></a></span><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif">   </span><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(146,39,143)">W:</span></b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif"> </span><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(0,176,240)"><a href="http://www.vivosight.com/" style="color:rgb(17,85,204)" target="_blank"><span style="color:rgb(0,176,240)">www.vivosight.com</span></a></span></p>


<p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"><br></p><p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"><a href="http://www.vivosight.com/" target="_blank"><span style="color:windowtext;text-decoration:none"><img src="https://sites.google.com/a/vivosight.com/logo/_/rsrc/1361922206747/home/VivoSight.png" border="0"></span></a></p>


<p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"><br></p><p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt"></p><p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt">


<span style="font-size:7.5pt;font-family:Arial,sans-serif;color:gray">Michelson Diagnostics Ltd, 1 Grays Farm Production Village, Grays Farm Road, Orpington, Kent  BR5 3BD, UK</span></p><p style="color:rgb(80,0,80);font-family:Calibri;margin:0cm 0cm 0.0001pt">


<span style="font-size:7.5pt;font-family:Arial,sans-serif;color:gray">Registered Office: 3 Shearwater, Maidstone, ME16 0DW.     Registered in England No. 5732681</span></p></div>
</div>
</div></div><br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>