ronfarkash commented on a change in pull request #11372:
URL: https://github.com/apache/pulsar/pull/11372#discussion_r675629177
##########
File path:
pulsar-common/src/main/java/org/apache/pulsar/common/util/RateLimiter.java
##########
@@ -203,7 +203,7 @@ public synchronized boolean tryAcquire(long acquirePermit) {
*
* @return returns 0 if permits is not available
*/
- public synchronized long getAvailablePermits() {
+ public long getAvailablePermits() {
Review comment:
The synchronized keyword blocked the RateLimiters to simultaneously
access each other's available permits. Since each RateLimiter is a side-task
that runs it's own instance of this function.
Since this function only reads from memory, and the variables which are read
are `volatile` means it'll be read directly from the main memory, I believe it
shouldn't damage anything.
I'm still pretty new to Java Concurrency though.
--
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]