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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top