|
Boost Users : |
Subject: Re: [Boost-users] [boost][thread] Future returning 0xfeeefeee
From: Klaim - Joël Lamotte (mjklaim_at_[hidden])
Date: 2013-04-07 15:24:44
On Sun, Apr 7, 2013 at 8:05 PM, Vicente J. Botet Escriba <
vicente.botet_at_[hidden]> 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<std::function<void()>> .
(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<void()> work; while( !end_of_work && m_task_queue.try_pop( work ) ) { work(); } } private: mutable tbb::concurrent_queue< std::function<void()> > m_task_queue; };
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