Replace per-bit listener count fields with an AtomicIntegerArray#2664
Draft
vogella wants to merge 1 commit into
Draft
Replace per-bit listener count fields with an AtomicIntegerArray#2664vogella wants to merge 1 commit into
vogella wants to merge 1 commit into
Conversation
ResourceChangeListenerList tracked per-event-type listener counts in six discrete volatile int fields (count1..count32), with adding(), removing(), hasListenerFor(), and clear() each duplicating a hard-coded switch over the same six bitmask values. Every new IResourceChangeEvent type required adding a field and four matching cases, and any mask bit that no one remembered to wire up was silently dropped by hasListenerFor. Collapse the bookkeeping into a single AtomicIntegerArray indexed by Integer.numberOfTrailingZeros(mask). adjust(mask, delta) walks the set bits of the mask once, replacing the two near-identical adding/removing helpers. hasListenerFor short-circuits non-single-bit and non-positive arguments, matching the previous switch's default-false behavior, and otherwise reads the counter for the single bit position. AtomicIntegerArray preserves the per-element volatile read semantics that hasListenerFor depends on outside the synchronized add/remove/clear paths. Drops the unreachable "listeners != null" guard in toString since the field is final and initialized at declaration, and inlines the ListenerEntry.toString StringBuilder into a concatenation expression for parity with the simplified outer toString.
Contributor
Member
These a valid points from AI point of view, but from human point of view:
So while change "technically" itself is OK, it makes debugging / maintenance harder for humans. |
Contributor
Author
|
I plan to add build events for individual projects and builder (requires events for projects), hence this change. This would allow clients to measure the build time of these builders on each project. No problem if it is rejected, still possible to add new events just ugly to do so. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Collapses the six volatile
count1..count32fields and the four near-identical switch/if-bit helpers inResourceChangeListenerListinto a singleAtomicIntegerArrayindexed byInteger.numberOfTrailingZeros(mask). The bookkeeping is now linear in the number of set bits, future event types are a no-op to support, andhasListenerForno longer silently drops anything outside the hard-coded 1..32 range. Behaviour and thread-safety guarantees are preserved.Planned for 4.41