The documentation for boost::lockfree::queue mentions that push can allocate more space if need be. However I can't for the life of me figure out how to instantiate such a queue and I can't find an example of it. All of the examples on boost's website are of fixed capacity.
This is the documentation I was looking at: http://www.boost.org/doc/libs/1_54_0/doc/html/boost/lockfree/queue.html
The default is for the queue to be variable sized. This is controlled by the typename ...Options
template parameter.
Further, there is a bug which in which the queue demands a statically set capacity, even when the queue is variable sized. This can be avoided by using the constructor that takes an initial capacity.
A variable sized queue can be instantiated as:
boost::lockfree::queue<T> newQueue(0);
// or equivalently:
boost::lockfree::queue<T, boost::lockfree::fixed_sized<false> > newQueue(0);
A fixed sized queue must explicitly set the fixed_sized
option to true
or supply a size with the boost::lockfree::capacity
option.
See the Policies
section near the start of the documentation that you linked to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With