jeanouii commented on code in PR #2276:
URL: https://github.com/apache/activemq/pull/2276#discussion_r4483162933
##########
activemq-client/src/main/java/org/apache/activemq/usage/Usage.java:
##########
@@ -276,6 +296,17 @@ protected void setPercentUsage(int value) {
}
}
+ /**
+ * Silently refresh the cached percentUsage (no listener events, no waiter
signalling) -
+ * used by the internal recompute sites in waitForSpace(long,int) and
isFull(int).
+ * Must be called with the usageLock write lock held. Subclasses that
cache values derived
+ * from percentUsage override this to refresh them in the same critical
section.
+ */
+ protected void refreshPercentUsage(int value) {
+ percentUsage = value;
+ bounds = PercentBounds.compute(value, limiter.getLimit(),
percentUsageMinDelta);
+ }
Review Comment:
Now that the set and the compute percentage is split in 2 operations outside
the sync block, we need to make sure that every time we read update the
percentage we potentially notify waiters.
I’m concerned about refreshPercentUsage which does the compute without the
signal. what do you think?
I would say that if the 100 -> less than 100 happens in the refresh, the
signal does not happen. And the fireEvent default implementation bellow which
was enough before with one sync block won’t pick up the change, because old
percentage isn”t 100 anymore and all blocked threads will remain blocked until
we reach 100 again, which can be never btw.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact