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
], 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