Boost logo

Boost :

Subject: Re: [boost] Building ThreadPool with boost::function in boost::lockfree::queue
From: Ryan Fogarty (ryan.fogarty.msece_at_[hidden])
Date: 2013-04-01 15:01:24

On Mon, Apr 1, 2013 at 11:51 AM, Tim Blechmann <tim_at_[hidden]> wrote:

> > In file included from TestFunctionCompleteness.cpp:11:0:
> > /usr/local/boost_1_53_0/include/boost/lockfree/queue.hpp: In
> instantiation
> > of ‘class boost::lockfree::queue<boost::function<void()> >’:
> > TestFunctionCompleteness.cpp:42:17: required from here
> > /usr/local/boost_1_53_0/include/boost/lockfree/queue.hpp:79:5: error:
> > static assertion failed: (boost::has_trivial_destructor<T>::value)
> > /usr/local/boost_1_53_0/include/boost/lockfree/queue.hpp:83:5: error:
> > static assertion failed: (boost::has_trivial_assign<T>::value)
> >
> >
> > Is boost::function somehow an incomplete type and not expected to work in
> > boost::lockfree::queue or is this a bug in the queue implementation? Can
> > anyone suggest a simple workaround?
> as the error message implies: boost::function is not trivially
> assignable and does not have a trivial destructor. so it cannot be used
> with boost::lockfree::queue.
> possible workaround: use a functor that meets these requirements
> hth, tim

Thanks Tim,

   I missed those restrictive requirements for queue. I just read your
responses here (
to another fellow and it looks like he was trying to build something almost
exactly like what I was trying to do. I guess the implication is that
lockfree::queue can't contain anything that is heap allocated (job functor
with data that requires handle) and still use safe C++ practices via a
handle idiom/RAII. That's too bad. If technically possible I would love to
see something like the concurrent_queue from TBB incorporated in your lib
(of course then it is relaxing the lockfree-ness of the data structure a
bit). TBB or a wrapped/synchronized deque will work well enough for me for
   If I am missing something trivial on how to preserve RAII between
producer and consumer(s) threads while messaging through your queue please
let me know!


Boost list run by bdawes at, gregod at, cpdaniel at, john at