lhotari commented on code in PR #21790:
URL: https://github.com/apache/pulsar/pull/21790#discussion_r1435158403


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/MemoryLimitController.java:
##########
@@ -47,6 +47,16 @@ public MemoryLimitController(long memoryLimitBytes, long 
triggerThreshold, Runna
 
     public void forceReserveMemory(long size) {
         long newUsage = currentUsage.addAndGet(size);
+        if (size < 0 && newUsage - size > memoryLimit

Review Comment:
   does `forceReserveMemory` allow negative values?



##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/MemoryLimitController.java:
##########
@@ -47,6 +47,16 @@ public MemoryLimitController(long memoryLimitBytes, long 
triggerThreshold, Runna
 
     public void forceReserveMemory(long size) {
         long newUsage = currentUsage.addAndGet(size);
+        if (size < 0 && newUsage - size > memoryLimit
+                && newUsage <= memoryLimit) {
+            // We just crossed the limit. Now we have more space
+            mutex.lock();
+            try {
+                condition.signalAll();
+            } finally {
+                mutex.unlock();
+            }

Review Comment:
   the code block is now duplicated in 2 methods. extract method?



-- 
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]

Reply via email to