If you put raw pointers in the queue, the old std::strings
will be leaked, since there is no way to free them when they are no longer needed. This is because there is no way to free the objects in a thread-safe way without taking a lock (other than some tricks like hazard pointers, which boost::lockfree::queue
does not use)
For technical reasons I do not really understand, the boost::lockfree::queue
requires a trivial assignment operator and a trivial destructor, which means that your object cannot be nor contain any data type that must free memory in its destructor, like std::string
.