C++0x, thread, promise and future
Jonathan Wakely
jwakely.gcc@gmail.com
Sat Jul 16 15:54:00 GMT 2011
On 16 July 2011 15:57, Claudio La Rosa wrote:
>
>
> Jonathan Wakely-4 wrote:
>>
>>
>>
>> Are you sure you get a segfault? You should get an exception in the
>> myAsyncFun thread, which is not caught so the program calls
>> std::teminate
>>
> Yes, I have a segmentation fault.
Ah, I think maybe that behaviour changed between 4.5 and 4.6
> Jonathan Wakely-4 wrote:
>>
>> You can't use a promise more than once, so your loop will always fail
>> on the second iteration.
>>
>
> Ok!
> Then this is the problem.
> But there is no way to create a promise that always works?
No. It's one use only. You could create a new promise and assign it
to the one that's been used, and get a new future from it, but making
that threadsafe would take additional synchronisation.
More information about the Gcc-help
mailing list