|
Boost Users : |
Subject: Re: [Boost-users] [LockFree] a queue of std::shared_ptr?
From: Johannes Stallkamp (jstallkamp_at_[hidden])
Date: 2013-02-15 10:43:42
Hi Chris,
Am 14.02.2013 19:17, schrieb chris:
> Hello All,
>
> If we can't use shared_ptr in a lockfree queue, how can I share data
> between different queue ?
>
> I have some data that I have to be put in different queues and I want to
> avoid that I have to copy this data for each queue.
>
We are in a similar situation concerning the need that the objects are
usually passed along as shared_ptr's but at some point need to be passed
to a worker thread via a lock-free queue.
To solve this problem, we allocate a copy of the shared_ptr on the heap
and pass the raw pointer (to the shared_ptr) into the queue. Of course,
in this case, the receiving worker thread needs to take care of deleting
the heap-allocated shared_ptr.
HTH,
Johannes
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