On Sun, Apr 7, 2013 at 8:05 PM, Vicente J. Botet Escriba <
vicente.botet@wanadoo.fr> wrote:
Maybe, there is a difference between the interface std::vector you use in
this example and your WorkQueue. Could you provide the prototype of the
functions you are using of WorkQueue?
Yes that's what I reported before: this code works until you use both
boost::future/promise AND WorkQueue. I currently fixed production my code
by just using std::future/promise.
I've provided the full source code of WorkQueue in my first mail. I'll
re-provide it here.
It's a thin wrapper around a tbb::concurrent_queue> .
(I'm using TBB 4.1 U2)
Unfortunately the only clue that I can think about is that this container
don't allow move-only value-type, so maybe it's linked to the problem
but if not I have no idea.
I also reported in the tbb forum see if they can spot something but the mix
makes things hard to understand.
Joel Lamotte
----
class WorkQueue
{
public:
template< class WorkTask >
void push( WorkTask&& task )
{
m_task_queue.push( std::forward<WorkTask>( task ) );
}
/** Execute all the work queued until now. */
void execute()
{
if( m_task_queue.empty() )
return;
bool end_of_work = false;
m_task_queue.push( [&]{ end_of_work = true; } );
std::function work;
while( !end_of_work && m_task_queue.try_pop( work ) )
{
work();
}
}
private:
mutable tbb::concurrent_queue< std::function > m_task_queue;
};