
15 Feb
2013
15 Feb
'13
3:43 p.m.
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