The main difference I see is the way the function is obtained:
When using vector the 'work' variable is a reference to the queue back, there is no move no assignment of function<void()> objects.
auto work = work_queue.back();
work_queue.pop_back();
When using tbb the 'work' variable is default constructed and copied using try_pop (see below).
I suspect that there could be an issue with the Boost.Thread implementation here.
std::function<void()> work;while( !end_of_work && m_task_queue.try_pop( work ) )
I don't master lambdas yet: does this the following code mean that work_queue is taken by reference and promise by value on the pushed lambda object?
auto do_some_work = [&]()-> boost::future<int*>
{
auto promise = std::make_shared<boost::promise<int*>>();
work_queue.push_back( [=]
{
promise->set_value( &TRUC );
});
return promise->get_future();
};