<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Apr 7, 2013 at 12:18 AM, Klaim - Joël Lamotte <span dir="ltr">&lt;<a href="mailto:mjklaim@gmail.com" target="_blank">mjklaim@gmail.com</a>&gt;</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>However the same change in a real code using WorkQueue internally and using similar code to the test </div>
<div>makes the future::get() provide invalid pointers with values close to 0x000000 but not exactly.<br>
</div><div>This code then makes access violation as the pointers are obviously not valid.</div></blockquote></div><br>Ok I found that my &quot;real code&quot; is actually buggy and indeed provide a wrong pointer (for a reason I&#39;ll have to hunt).</div>
<div class="gmail_extra" style>So don&#39;t bother, std::future/promise does work with my test and real code using WorkQueue/tbb::concurrent_queue</div><div class="gmail_extra" style> but boost::future/promise doesnt.</div>
<div class="gmail_extra" style><br></div><div class="gmail_extra" style>I also simplified the test (and real) code for clarity, it should be equivalent to the code from my first post:</div><div class="gmail_extra" style><br>
</div><div class="gmail_extra" style><div class="gmail_extra"><span class="" style="white-space:pre">	</span>int TRUC = 42;</div><div class="gmail_extra">TEST( Test_WorkQueue, future_promise_shared_work )</div><div class="gmail_extra">
{</div><div class="gmail_extra"><span class="" style="white-space:pre">	</span>WorkQueue work_queue;</div><div class="gmail_extra"><br></div><div class="gmail_extra"><span class="" style="white-space:pre">	</span>auto do_some_work = [&amp;]()-&gt; std::future&lt;int*&gt;</div>
<div class="gmail_extra"><span class="" style="white-space:pre">	</span>{</div><div class="gmail_extra"><span class="" style="white-space:pre">		</span>auto promise = std::make_shared&lt;std::promise&lt;int*&gt;&gt;();</div>
<div class="gmail_extra"><span class="" style="white-space:pre">		</span>work_queue.push( [=]</div><div class="gmail_extra"><span class="" style="white-space:pre">		</span>{</div><div class="gmail_extra"><span class="" style="white-space:pre">			</span>promise-&gt;set_value( &amp;TRUC );</div>
<div class="gmail_extra"><span class="" style="white-space:pre">		</span>});</div><div class="gmail_extra"><br></div><div class="gmail_extra"><span class="" style="white-space:pre">		</span>return promise-&gt;get_future();</div>
<div class="gmail_extra"><span class="" style="white-space:pre">	</span>};</div><div class="gmail_extra"><br></div><div class="gmail_extra"><span class="" style="white-space:pre">	</span>auto ft_value = do_some_work();</div>
<div class="gmail_extra"><br></div><div class="gmail_extra"><span class="" style="white-space:pre">	</span>work_queue.execute();</div><div class="gmail_extra"><br></div><div class="gmail_extra"><span class="" style="white-space:pre">	</span>auto value = ft_value.get();</div>
<div class="gmail_extra"><span class="" style="white-space:pre">	</span>ASSERT_EQ( &amp;TRUC, value );</div><div class="gmail_extra">}</div><div class="gmail_extra"><br></div></div></div>