Why is the boost lockfree size is fixed to 65535 objects?
typedef boost::lockfree::queue<int, boost::lockfree::fixed_size<true>> MyQueue;
MyQueue queue(1024*100);
The above code throws exception.
the reasoning i find in the code is that array-based freelists only support a 16bit address space.
what is the reason for this? i am using it on 64bit linux machine. then why limit the addressing to 2**16 items? does the queue use a 'short int' for indexing? does atomic instructions only work for 16bit word size?
what should i do to have a fixed sized queue with more capacity than this?
Boost implementation of lockfree list has to fight the ABA problem. A common workaround is to add extra tag
bits to the quantity being considered. Furthermore, Boost has to run on a 32-bit architecture, this means only 32-bit values can be manipulated atomically.
And if we split 32-bit value we can store 16-bit pointers and 16-bit tag. Unsigned 16-bit values are limited to 65535 different values.
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