This method is fine, but with it you must always take care to choose bufsize as a power of two, otherwise the overhead of having to do integer divisions for all queue operations may be noticeable.
> but with it you must always take care to choose bufsize as a power of two, otherwise the overhead of having to do integer divisions
Keep in mind that one of the reasons behind the arbitrary "power of two" requirement is that the method proposed by the author abuses a single atomic integer to hold two shorts representing the indices for the head and tail elements.
I don't think it makes much sense to talk about overhead given this method requires doing a bunch of bitmasks to operate over the high and low short.
Keep in mind that one of the reasons behind the arbitrary "power of two" requirement is that the method proposed by the author abuses a single atomic integer to hold two shorts representing the indices for the head and tail elements.
I don't think it makes much sense to talk about overhead given this method requires doing a bunch of bitmasks to operate over the high and low short.