Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost][thread] Future returning 0xfeeefeee
From: Klaim - Joël Lamotte (mjklaim_at_[hidden])
Date: 2013-04-06 18:40:36


On Sun, Apr 7, 2013 at 12:18 AM, Klaim - Joël Lamotte <mjklaim_at_[hidden]>wrote:

> However the same change in a real code using WorkQueue internally and
> using similar code to the test
> makes the future::get() provide invalid pointers with values close to
> 0x000000 but not exactly.
> This code then makes access violation as the pointers are obviously not
> valid.
>

Ok I found that my "real code" is actually buggy and indeed provide a wrong
pointer (for a reason I'll have to hunt).
So don't bother, std::future/promise does work with my test and real code
using WorkQueue/tbb::concurrent_queue
 but boost::future/promise doesnt.

I also simplified the test (and real) code for clarity, it should be
equivalent to the code from my first post:

int TRUC = 42;
TEST( Test_WorkQueue, future_promise_shared_work )
{
WorkQueue work_queue;

auto do_some_work = [&]()-> std::future<int*>
{
auto promise = std::make_shared<std::promise<int*>>();
work_queue.push( [=]
{
promise->set_value( &TRUC );
});

return promise->get_future();
};

auto ft_value = do_some_work();

work_queue.execute();

auto value = ft_value.get();
ASSERT_EQ( &TRUC, value );
}



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net