RFR: 8263551: Provide shared lock-free FIFO queue implementation
Kim Barrett
kbarrett at openjdk.java.net
Mon Mar 15 23:28:12 UTC 2021
On Mon, 15 Mar 2021 20:01:42 GMT, Man Cao <manc at openjdk.org> wrote:
>> src/hotspot/share/utilities/lockFreeQueue.hpp line 50:
>>
>>> 48: NONCOPYABLE(LockFreeQueue);
>>> 49:
>>> 50: protected:
>>
>> Protected members (to be accessible from a derived class) are inconsistent with a public non-virtual destructor (that may allow destructor slicing). I dislike classes that try to be both concrete implementation classes and base classes; they are hard to design well (and this class wasn't intended to be such). This was done to allow G1DirtyCardQueueSet to extend it with the `take_all` function; that seems like a useful operation in the generic form, even if it can't be made thread-safe. (The G1 function asserts_at_safepoint(), but that's not really appropriate for a generic form.)
>
> To clarify, do we want to move take_all() to LockFreeQueue, remove assert_at_safepoint() and put a big warning that it is not thread safe? It perhaps also involves adding the "struct HeadTail" to this class.
>
> Another option is to provide two getter methods that returns T** for &_head and &_tail. They are not thread-safe either, but maybe more generic than take_all().
Either of those options seems okay, though the two getters exposes more of the implementation details. The existing take_all is already described as not thread-safe. HeadTail => `Pair<T*, T*>` would work.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2986
More information about the hotspot-dev
mailing list