<br><br><div class="gmail_quote">On Sat, May 29, 2010 at 5:46 PM, Sebastian Trüg <span dir="ltr">&lt;<a href="mailto:trueg@kde.org">trueg@kde.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hehe, this does not help at all. Think about it: in my example there are<br>
2 Resource instances involved. Thus: 2 mutexes which are locked<br>
independent of each other. :)<br>
The mutex is already there in ResourceData. It simply needs to be locked<br>
in Resource instead of ResourceData::determineUri.<br>
<br></blockquote><div><br>Uhh I&#39;m confused. Why don&#39;t you handle the multi-threading? <br><br>I should really learn about multi-threading. If you have a couple of spare minutes could you explain why my method won&#39;t work?<br>
<br>My rationale -<br><br>Thread 1 :<br><div style="margin-left: 40px;">Resource r1(&quot;foo&quot;);<br>r1.property( nao:numericRating )<br>-&gt; the mutex is locked<br>-&gt; performs whatever and determines the uri<br><br>
</div>Thread 2 :<br><div style="margin-left: 40px;">Resource r2(&quot;foo&quot;);<br>r2.setProperty( whatever )<br>-&gt; the mutex can&#39;t get locked so it waits till it does<br>-&gt; mutex now locked. Thread 1 should have determined the uri by now<br>
-&gt; perform operation<br></div><br>Thanks<br>- Vishesh Handa<br><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Cheers,<br>
<font color="#888888">Sebastian<br>
</font><div class="im"><br>
On 05/29/2010 01:19 PM, Vishesh Handa wrote:<br>
&gt; How about this?<br>
&gt;<br>
&gt; I didn&#39;t know where to add the Mutex, and I didn&#39;t think ResourceData<br>
&gt; would be appropriate. So, I implemented the Resource::Private class and<br>
&gt; added it over there. This should not break binary compatibility as it<br>
&gt; already existed. Or is there a better way?<br>
&gt;<br>
&gt; - Vishesh Handa<br>
&gt;<br>
&gt; On Sat, May 29, 2010 at 2:25 PM, Vishesh Handa &lt;<a href="mailto:handa.vish@gmail.com">handa.vish@gmail.com</a><br>
</div><div class="im">&gt; &lt;mailto:<a href="mailto:handa.vish@gmail.com">handa.vish@gmail.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     Hey Sebastian<br>
&gt;<br>
&gt;     I&#39;m sorry for the late reply I was busy with college stuff.<br>
&gt;<br>
&gt;     I looked at the modified patch, and I like the fact that it works,<br>
&gt;     but I don&#39;t like the fact that we have to remember additional stuff.<br>
&gt;     DetermineUri() must not me called inside ResourceData, and that<br>
&gt;     you&#39;ll probably have to check if the ResourceData is stored() and<br>
&gt;     its uri has been determined, before calling a method. These small<br>
&gt;     things then to add up, and clutter the Resource Code.<br>
&gt;<br>
&gt;     Ideally I would have liked ResourceData to do all this checking<br>
&gt;     itself, so that when altering the Resource class we don&#39;t have to<br>
&gt;     worry about it. ( But then we already had to worry about store() ) I<br>
&gt;     don&#39;t have a solution, but I&#39;m trying to figure out one.<br>
&gt;<br>
&gt;     I never even thought about multi-threading before this, and, yes, I<br>
&gt;     too think it will crash. ( Time to add more tests? Can we add<br>
&gt;     multi-threading tests? )  I was thinking of some way of checking if<br>
&gt;     the determineUri lock exists, and then accordingly calling<br>
&gt;     determineUri() from Resource, but I think your method of mutex<br>
&gt;     locking the Resource should cover it.<br>
&gt;<br>
&gt;     I&#39;ll try to implement it (It pretty simple, right?)<br>
&gt;<br>
&gt;     - Vishesh Handa<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;     On Thu, May 27, 2010 at 5:29 PM, Sebastian Trüg &lt;<a href="mailto:trueg@kde.org">trueg@kde.org</a><br>
</div><div class="im">&gt;     &lt;mailto:<a href="mailto:trueg@kde.org">trueg@kde.org</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;         Hi Vishesh,<br>
&gt;<br>
&gt;         I finally looked at the remove-proxy patch again and fixed it.<br>
&gt;         Now the<br>
&gt;         only problem left is the design weirdness of ResourceData instances<br>
&gt;         deleting themselves.<br>
&gt;<br>
&gt;         The main thing I did was removing all calls to determineUri from<br>
&gt;         ResourceData and moving them into Resource. I did the same with<br>
&gt;         load()<br>
&gt;         and store() which is actually not necessary. Maybe it would be<br>
&gt;         cleaner<br>
&gt;         to move those back...<br>
&gt;<br>
&gt;         I did not look into the merging of load and determineUri yet. I<br>
&gt;         think we<br>
&gt;         should do that in a separate patch only after we cleaned this<br>
&gt;         one up.<br>
&gt;         Otherwise it is impossible to debug.<br>
&gt;<br>
&gt;         Cheers,<br>
&gt;         Sebastian<br>
&gt;<br>
&gt;         On 05/26/2010 12:52 PM, Vishesh Handa wrote:<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt; On Wed, May 26, 2010 at 3:13 PM, Sebastian Trüg &lt;<a href="mailto:trueg@kde.org">trueg@kde.org</a><br>
&gt;         &lt;mailto:<a href="mailto:trueg@kde.org">trueg@kde.org</a>&gt;<br>
</div><div><div></div><div class="h5">&gt;         &gt; &lt;mailto:<a href="mailto:trueg@kde.org">trueg@kde.org</a> &lt;mailto:<a href="mailto:trueg@kde.org">trueg@kde.org</a>&gt;&gt;&gt; wrote:<br>
&gt;         &gt;<br>
&gt;         &gt;     On 05/26/2010 10:08 AM, Vishesh Handa wrote:<br>
&gt;         &gt;     &gt;     &gt; 3. When checking if the the m_kickoffUri is a<br>
&gt;         nie:url for a<br>
&gt;         &gt;     resource.<br>
&gt;         &gt;     &gt;     &gt; The nieUrl is assigned to be equal to the uri.<br>
&gt;         This however<br>
&gt;         &gt;     gets fixed<br>
&gt;         &gt;     &gt;     &gt; in the load(). And nieUrl isn&#39;t used anywhere, so<br>
&gt;         it doesn&#39;t<br>
&gt;         &gt;     &gt;     matter that<br>
&gt;         &gt;     &gt;     &gt; much.<br>
&gt;         &gt;     &gt;<br>
&gt;         &gt;     &gt;     I suppose you mean this part:<br>
&gt;         &gt;     &gt;<br>
&gt;         &gt;     &gt;     if( it.next() ) {<br>
&gt;         &gt;     &gt;          QUrl uri = it[&quot;r&quot;].uri();<br>
&gt;         &gt;     &gt;          if( uri.isEmpty() ) {<br>
&gt;         &gt;     &gt;             m_uri = m_kickoffUri;<br>
&gt;         &gt;     &gt;          }<br>
&gt;         &gt;     &gt;          else {<br>
&gt;         &gt;     &gt;             m_uri = uri;<br>
&gt;         &gt;     &gt;             m_nieUrl = uri;<br>
&gt;         &gt;     &gt;          }<br>
&gt;         &gt;     &gt;<br>
&gt;         &gt;     &gt;     The last two lines. AFAICT this is perfectly fine<br>
&gt;         since in the<br>
&gt;         &gt;     latter<br>
&gt;         &gt;     &gt;     case both nie:url and resource URI are equal.<br>
&gt;         &gt;     &gt;<br>
&gt;         &gt;     &gt;<br>
&gt;         &gt;     &gt; I respectfully disagree. :)<br>
&gt;         &gt;     &gt;<br>
&gt;         &gt;     &gt; The query used is this &quot;select distinct ?r ?o where { {<br>
&gt;         ?r nie:url<br>
&gt;         &gt;     &lt;uri&gt;<br>
&gt;         &gt;     &gt; . } UNION { &lt;uri&gt; ?p ?o . }  } LIMIT 1&quot;. The case where<br>
&gt;         ?r isn&#39;t empty<br>
&gt;         &gt;     &gt; is when the &lt;uri&gt; contains the nie:url and therefore ?r will<br>
&gt;         &gt;     contain the<br>
&gt;         &gt;     &gt; resource uri.<br>
&gt;         &gt;<br>
&gt;         &gt;     You are of course correct. It should be &quot;m_nieUrl =<br>
&gt;         m_kickoffUri&quot;<br>
&gt;         &gt;     instead. Agreed?<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt; Yup. :)<br>
&gt;         &gt;<br>
&gt;         &gt; If you get the time could you please look at my horrible merge<br>
&gt;         patch?<br>
&gt;         &gt;<br>
&gt;         &gt; Thanks<br>
&gt;         &gt; - Vishesh Handa<br>
&gt;         &gt;<br>
&gt;         &gt;     Cheers,<br>
&gt;         &gt;     Sebastian<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br>