I would like to implement a simple publish / publish template where:
One publisher publishes a token (pointer to an object) to its subscribers. Publisher and subscribers are all independent streams. I plan to add a thread-safe queue to each subscriber so that the publisher can continue to distribute tokens to subscribers while they process the tokens.
As you can see, this means that all subscribers actually use the same pointers (note: subscribers cannot change a pointed object in any case, so there are no problems). As soon as the shared index will no longer be used by any of the subscribers, it would be very nice if the index could automatically delete itself as soon as the last thread of the subscriber is executed with it.
Is this a good place to use smart pointer? If so, which of the smart pointers should I use?
I am developing Windows using MSVC2008 and using Intel TBB, Boost and Qt.
source
share