New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
a question about mspc buffer array index #390
Comments
Your source code seems to be copied from LinkedArrayQueueUtil. To answer this method and the meaning of its parameters, it's necessary to understand the layout of an Object[] object in the JVM heap:
Next, let's answer the meaning of the parameter index:
Regarding whether index is doubled: Yes, due to the presence of the trailing flag bit, index defaults to twice the value of arrayIndex. You can find more details in the assignment operation of ConsumerIndex in BaseMpscLinkedArrayQueue. |
hank you very much for your kind words. I'm glad to hear that you found the response clear and understandable. If you have any more questions or need further assistance, feel free to ask. |
i has a question about offset compute.
the jctools compute code is:
/**
* This method assumes index is actually (index << 1) because lower bit is
* used for resize. This is compensated for by reducing the element shift.
* The computation is constant folded, so there's no cost.
*/
public static long modifiedCalcCircularRefElementOffset(long index, long mask)
{
return REF_ARRAY_BASE + ((index & mask) << (REF_ELEMENT_SHIFT - 1));
}
REF_ARRAY_BASE is the array base address in memeory from JVM。
i know that the function is to compute zhe address in jvm for a array with index and mask.
but i find the index is not item in array index .
my question is the function input param index :
what the param means? it is double to array index?
The text was updated successfully, but these errors were encountered: