Hi,

I am trying to get my head around to why you need

 i >= n || i + n >= nextn

https://github.com/openjdk/jdk/blob/af5bf81754072fa5879726cfacb7404892b553f0/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java#L2465


in the transfer method of the CHM.

https://github.com/openjdk/jdk/blob/af5bf81754072fa5879726cfacb7404892b553f0/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java#L2426

The reasons why I think that this is not required is because :

1) At a time there can be only 1 active transfer. Since there is only one
table variable and only one newTable variable.

2) transferIndex is always set to oldTable.length before a transfer() takes
place

https://github.com/openjdk/jdk/blob/af5bf81754072fa5879726cfacb7404892b553f0/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java#L2440

3) transferIndex is always set to nextIndex - stride, nextIndex is always
set to transferIndex which in turn is always set to n (oldTable.length)

https://github.com/openjdk/jdk/blob/af5bf81754072fa5879726cfacb7404892b553f0/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java#L2456

https://github.com/openjdk/jdk/blob/af5bf81754072fa5879726cfacb7404892b553f0/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java#L2452

4) All threads that modifies the CHM must help with the transfer() before
finalizing the newTable

https://github.com/openjdk/jdk/blob/af5bf81754072fa5879726cfacb7404892b553f0/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java#L2467

Please let me know if I am going wrong anywhere

or if there are any code paths which can make i >=n when advance = false

Any help would be great.
-- 
Regards,
Sreyan Chakravarty

Reply via email to