Subject: Re: [boost] Futures Review - Should packaged_taskbeCopyConstructible?
From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2009-02-11 03:31:27
"vicente.botet" <vicente.botet_at_[hidden]> writes:
> Sorry i was not clear. The problem is that the reference to the task
> std::packaged_task<result_type> task(std::move(f));
> has been stored in the set_wait_callback. But this address is no more
> valable when the function returns, so when the user gets the future
> and call to get, the callback uses a bad address. Hoping it is clear
Yes, it's clear. That's a design issue with set_wait_callback.
> Ok, I see. Anyway, I think that examples like
> template<typename F>
> std::packaged_task<typename std::result_of<F()>::type> lazy_call(F f);
> should be included in the library, at least as an example.
That's a good idea.
-- Author of C++ Concurrency in Action | http://www.manning.com/williams just::thread C++0x thread library | http://www.stdthread.co.uk Just Software Solutions Ltd | http://www.justsoftwaresolutions.co.uk 15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976