You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/05/04 06:23:53 UTC

[GitHub] [pulsar] 315157973 commented on a change in pull request #10352: Make Consumer thread safe and lock-free

315157973 commented on a change in pull request #10352:
URL: https://github.com/apache/pulsar/pull/10352#discussion_r625533508



##########
File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java
##########
@@ -1292,17 +1280,15 @@ void receiveIndividualMessagesFromBatch(MessageMetadata msgMetadata, int redeliv
                 if (possibleToDeadLetter != null) {
                     possibleToDeadLetter.add(message);
                 }
-                lock.readLock().lock();
-                try {
+                internalPinnedExecutor.execute(() -> {
                     if (peekPendingReceive() != null) {
                         notifyPendingReceivedCallback(message, null);
                     } else if (enqueueMessageAndCheckBatchReceive(message) && hasPendingBatchReceive()) {
                         notifyPendingBatchReceivedCallBack();
                     }
-                } finally {
-                    lock.readLock().unlock();
-                }
-                singleMessagePayload.release();
+                    singleMessagePayload.release();
+                    tryTriggerListener();

Review comment:
       The behavior here is consistent, the previous logic is
   ```
   if(){
   }else{
   }
   triggerListener
   ```
   I just put the triggerListener into the if and else respectively.
   
   If I don’t do this, triggerListener will execute in parallel with the if-else logic
   




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org