RFR: 8263551: Provide shared lock-free FIFO queue implementation

Kim Barrett kbarrett at openjdk.java.net
Sun Mar 14 02:42:09 UTC 2021


On Sun, 14 Mar 2021 00:55:02 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> Hi all,
>> 
>> Could anyone review this change that is mainly code motion? It creates a generalized lock-free queue implementation based on G1DirtyCardQueueSet::Queue, which will be used by JDK-8236485 in the future.
>> 
>> The shared LockFreeQueue is similar to the existing LockFreeStack. The notable difference is that the LockFreeQueue has an additional template parameter for whether to use GlobalCounter::CriticalSection to avoid ABA problem.
>> 
>> -Man
>
> src/hotspot/share/utilities/lockFreeQueue.hpp line 113:
> 
>> 111:   // Return the entry following value in the list used by the
>> 112:   // specialized LockFreeQueue class.
>> 113:   static T* get_next(const T& value) {
> 
> I think this function should not be public; it's needed internal to the implementation of this class, but if a client needs access to the next list entry it should be getting it via a member on T, assuming T provides such.  And if it doesn't, well, you probably aren't supposed to be doing that.  I see that LockFreeStack has public next and set_next; by that argument they should be private too.  (I think the only reason they can't currently be private is because of unit tests, which could be fixed.)

As mentioned elsewhere, I think there should be an associated set_next.

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

PR: https://git.openjdk.java.net/jdk/pull/2986


More information about the hotspot-dev mailing list