<div dir="ltr">Denis,<div><br></div><div>Thank you for reviewing! This code was submitted in r226336 and the final code doesn't have the issues that you pointed out, I believe.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 19, 2015 at 5:17 AM, Denis Protivensky <span dir="ltr"><<a href="mailto:dprotivensky@accesssoftek.com" target="_blank">dprotivensky@accesssoftek.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">My in-place comment doesn't submit for some reason, so I put it here:<br>
<br>
lib/ReaderWriter/FileArchive.cpp:105<br>
<br>
_promises[index].set_value(nullptr);<br>
<br>
Here is also a concurrency issue.<br>
<br>
_promises[index] returns a reference to the promise object stored in the vector. If before making set_value() the vector's memory is moved because of reallocation in the other thread (new element inserted), the returned reference will again be invalid as it was in the previous version of the code when capturing promise by reference.<br>
<br>
One of the solutions is to avoid vector reallocations. So we need either to reserve some sufficient element count beforehand, or to change vector to deque, for example.<br>
<br>
<br>
================<br>
Comment at: lib/ReaderWriter/FileArchive.cpp:105<br>
@@ +104,3 @@<br>
+ if (instantiateMember(ci, result)) {<br>
+ _promises[index].set_value(nullptr);<br>
+ return;<br>
----------------<br>
Here is also a concurrency issue.<br>
<br>
_promises[index] returns a reference to the promise object stored in the vector. If before making set_value() the vector's memory is moved because of reallocation in the other thread (new element inserted), the returned reference will again be invalid as it was in the previous version of the code when capturing promise by reference.<br>
<br>
One of the solutions is to avoid vector reallocations. So we need either to reserve some sufficient element count beforehand, or to change vector to deque, for example.<br>
<div class="HOEnZb"><div class="h5"><br>
<a href="http://reviews.llvm.org/D7015" target="_blank">http://reviews.llvm.org/D7015</a><br>
<br>
EMAIL PREFERENCES<br>
<a href="http://reviews.llvm.org/settings/panel/emailpreferences/" target="_blank">http://reviews.llvm.org/settings/panel/emailpreferences/</a><br>
<br>
<br>
</div></div></blockquote></div><br></div>