Promise, future and thread on C++0x

Jonathan Wakely jwakely.gcc@gmail.com
Thu Jul 7 09:49:00 GMT 2011


On 7 July 2011 10:47, Jonathan Wakely wrote:
> On 7 July 2011 10:29, Claudio La Rosa wrote:
>>
>> Ok, but there is no simple way to work around the problem?
>
> Pass the promise by lvalue reference:
>
> void myAsyncFun(promise<int>& intPromise)
> { ... }
>

N.B. your program will call std::terminate because you do not join or
detach the thread before its destructor runs.

You should call t.join() before returning from main.



More information about the Libstdc++ mailing list