Boost logo

Boost Users :

Subject: Re: [Boost-users] why lockfree/queue.hpp requires has_trivial_assign and has_trivial_destructor to template type T
From: Bjorn Reese (breese_at_[hidden])
Date: 2014-08-05 07:52:42


On 08/05/2014 08:48 AM, 何子杰Hzj_jie wrote:

> it looks like an implementation limitation to me. the pointer surely
> works, but it will cause trouble about the instance lifetime. my

I believe that the limitation is inherited from atomic<>. If it is any
consolation, there is ongoing work to allow smart pointers in atomic<>:

   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4058.pdf

> scenario is a threadpool, which will work on functions / lambdas
> [function<bool(void)>], so let the threadpool queue keeps the instances
> would be an easy approach. but multi-produce-multi-consume is required.

By only having the next available thread listening on the consumer side
you can reduce this to MCSP. See the Leader/Followers architectural
pattern on how this can be done (but do notice that the threadpool has
locks)

   http://www.cs.wustl.edu/~schmidt/PDF/lf.pdf


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