<br><font size=2 face="sans-serif">Hi,</font>
<br>
<br><font size=2 face="sans-serif">I think we should be carefull about
the multithreading improvements. </font>
<br><font size=2 face="sans-serif">They are certainly necessary, but some
carefull tests are needed to see if multithreading should be supported
implicitely, with potential performance issues, or explicitely, with some
overhead for developers.</font>
<br>
<br><font size=2 face="sans-serif">I am more in favor of being explicit,
at least now that we are only trying to find the best programming model.
</font>
<br><font size=2 face="sans-serif">Maybe a class vtkThreadedWeakPointer
with critical section?</font>
<br>
<br><font size=2 face="sans-serif">Stephane<br>
</font>
<table>
<tr valign=top>
<td rowspan=2><font size=2 face="sans-serif"> </font><img src=cid:_1_08D96CB408D968CC004948CAC12577BA><font size=2 face="sans-serif">
</font>
<td><font size=1 face="sans-serif"> </font>
<tr valign=top>
<td><font size=1 color=#ff8100 face="Arial"><b>Stephane PLOIX</b></font><font size=1 color=#ff8100 face="Arial"><b><br>
Pilote Opérationnel - Visualisation scientifique</b></font><font size=1 color=#0062e1 face="Arial"><br>
EDF - R&D<br>
SINETICS<br>
1, Av du Général de Gaulle<br>
92140 Clamart</font><font size=1 color=#0062e1 face="sans-serif"><br>
 </font>
<br><font size=1 color=#0062e1 face="Arial"><b>stephane.ploix@edf.fr</b></font>
<br><font size=1 color=#0062e1 face="Arial">Tél. : +33 (0) 1 47 65 51
10</font>
<tr>
<td valign=top><font size=2 face="sans-serif"> </font><img src=cid:_1_08D97BC808D977E0004948CAC12577BA><font size=2 face="sans-serif">
</font>
<td><font size=1 color=#0062e1 face="Arial">Un geste simple pour l'environnement,
n'imprimez ce message que si vous en avez l'utilité.</font></table>
<br>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>will.schroeder@kitware.com</b>
</font>
<br><font size=1 face="sans-serif">Envoyé par : vtk-developers-bounces@vtk.org</font>
<p><font size=1 face="sans-serif">12/10/2010 12:32</font>
<td width=59%>
<table width=100%>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">A</font></div>
<td><font size=1 face="sans-serif">david.gobbi@gmail.com</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td><font size=1 face="sans-serif">vtk-developers@vtk.org</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Objet</font></div>
<td><font size=1 face="sans-serif">Re: [vtk-developers] Weak pointers and
thread safety</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><font size=3>How would this impact performance? Would it improve it
do you think?</font>
<br><font size=3>W</font>
<br><font size=3><br>
</font>
<br><font size=3>On Mon, Oct 11, 2010 at 10:35 PM, David Gobbi <</font><a href=mailto:david.gobbi@gmail.com><font size=3 color=blue><u>david.gobbi@gmail.com</u></font></a><font size=3>>
wrote:</font>
<br><font size=3>Hi All,<br>
<br>
The VTK weak pointer implementation is not thread safe because it can<br>
be used just like a regular pointer, even though the object itself<br>
might be deleted by a separate thread at any time.<br>
<br>
By comparison, "safe" weak pointer like in boost and Qt cannot
be used<br>
in place of ordinary pointers.  Instead, in order to use them their<br>
"GetPointer()"-like methods increment the reference count and
then<br>
return a smart pointer, which is guaranteed to be valid until it goes<br>
out of scope:<br>
<br>
vtkSmartPointer<SomeClass> smartPtr = weakPtr.GetPointer();<br>
if (smartPtr.GetPointer() != 0)<br>
 {<br>
 // do something with smartPtr<br>
 }<br>
// reference count decremented when smartPtr goes out of scope<br>
<br>
Because VTK's vtkWeakPointer::GetPointer() does not return a smart<br>
pointer or do any thread locking, thread-safe use of vtkWeakPointer<br>
requires the following:<br>
<br>
vtkSimpleCriticalSection critSec;<br>
critSec.Lock();<br>
vtkSmartPointer<SomeClass> smartPtr = weakPtr.GetPointer();<br>
critSec.Unlock();<br>
if (smartPtr.GetPointer() != 0)<br>
 {<br>
 // do something with smartPtr<br>
 }<br>
<br>
If weakPtr.GetPointer() was changed to return a smart pointer, then it<br>
could do the locking internally.  This change would be mostly, but
not<br>
completely, backwards compatible.  What do people think?<br>
<br>
 David<br>
_______________________________________________<br>
Powered by </font><a href=http://www.kitware.com/ target=_blank><font size=3 color=blue><u>www.kitware.com</u></font></a><font size=3><br>
<br>
Visit other Kitware open-source projects at </font><a href=http://www.kitware.com/opensource/opensource.html target=_blank><font size=3 color=blue><u>http://www.kitware.com/opensource/opensource.html</u></font></a><font size=3><br>
<br>
Follow this link to subscribe/unsubscribe:</font><font size=3 color=blue><u><br>
</u></font><a href="http://www.vtk.org/mailman/listinfo/vtk-developers" target=_blank><font size=3 color=blue><u>http://www.vtk.org/mailman/listinfo/vtk-developers</u></font></a><font size=3><br>
</font>
<br><font size=3><br>
<br>
<br>
-- <br>
William J. Schroeder, PhD<br>
Kitware, Inc.<br>
28 Corporate Drive<br>
Clifton Park, NY 12065</font><font size=3 color=blue><u><br>
</u></font><a href=mailto:will.schroeder@kitware.com><font size=3 color=blue><u>will.schroeder@kitware.com</u></font></a><font size=3 color=blue><u><br>
</u></font><a href=http://www.kitware.com/><font size=3 color=blue><u>http://www.kitware.com</u></font></a><font size=3><br>
(518) 881-4902</font><tt><font size=2>_______________________________________________<br>
Powered by www.kitware.com<br>
<br>
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html<br>
<br>
Follow this link to subscribe/unsubscribe:<br>
http://www.vtk.org/mailman/listinfo/vtk-developers<br>
<br>
</font></tt>
<br><font face="monospace"><br>
<br>
<br>
Ce message et toutes les pièces jointes (ci-après le 'Message') sont établis à l'intention exclusive des destinataires et les informations qui y figurent sont strictement confidentielles. Toute utilisation de ce Message non conforme à sa destination, toute diffusion ou toute publication totale ou partielle, est interdite sauf autorisation expresse.<br>
<br>
Si vous n'êtes pas le destinataire de ce Message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si vous avez reçu ce Message par erreur, merci de le supprimer de votre système, ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support que ce soit. Nous vous remercions également d'en avertir immédiatement l'expéditeur par retour du message.<br>
<br>
Il est impossible de garantir que les communications par messagerie électronique arrivent en temps utile, sont sécurisées ou dénuées de toute erreur ou virus.<br>
____________________________________________________<br>
<br>
This message and any attachments (the 'Message') are intended solely for the addressees. The information contained in this Message is confidential. Any use of information contained in this Message not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval.<br>
<br>
If you are not the addressee, you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return message.<br>
<br>
E-mail communication cannot be guaranteed to be timely secure, error or virus-free.</font>