RFR: 8189088: Add intrusive doubly-linked list utility [v3]

Kim Barrett kbarrett at openjdk.org
Sat Oct 7 20:42:17 UTC 2023


On Wed, 4 Oct 2023 09:57:45 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

> Regarding the mechanism for accessing the entry of an element, I'm now thinking a function-based mechanism (like NonblockingQueue and LockFreeStack) is better than the pointer-to-data-member mechanism currently used here. The benefit of a function-based mechanism is that it doesn't require the element type to be complete at the point of list declaration. It also avoids the need for an MSVC workaround.

Using a function accessor rather than a pointer-to-data-member is more
general. I've already mentioned that it permits list declarations with an
incomplete element type. It also permits Entry objects being arbitrary
subobjects. For example, an object could support being in multiple lists by
having an array of Entry objects, with an array index per list. A
pointer-to-data-member can't designate an individual element of an array
member. (One could also have Entry class base class, which also can't be
designated by a pointer-to-data-member, but I doubt that's a realistic
use-case.) The pointer-to-data-member approach also seems prone to obscure
corner-case compiler bugs (one of which, as noted, requires a workaround in
this PR, e.g. affects a currently in-use compiler).

-------------

PR Comment: https://git.openjdk.org/jdk/pull/15896#issuecomment-1751813462


More information about the hotspot-dev mailing list