remove any Reentrant locks in favor of a CAS linked list #241
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
This PR removes any usage of Reentrant Lock in DataLoader in favor of using a self made Linked List and updates to it via AtomicReference CAS.
CacheMap change
This is a breaking change for the future cache
CacheMap.In order to avoid any locking
was replaced with
which is required to be atomic (like for example offered by ConcurrendHashMap)
This requirement also means that the underlying cache implementation must support this atomic operation.
Concurrent loads without batching, but with caching
Previously it was guaranteed that for one key with caching enabled and batching disabled, the dispatching only happens once.
Now because we avoid any form on lock this is not guaranteed anymore: there could be unnecessary dispatch calls when concurrent load calls are happening.
TODO: Update tests to avoid Collections.reverse
See https://github.com/graphql-java/java-dataloader/pull/241/files#diff-e44f0238fddb1d168a414ceef18d7194686b83ecf167cb794d2d03e714494c88R259