jai1 commented on a change in pull request #577: CPP add receiveAsync API
URL: https://github.com/apache/incubator-pulsar/pull/577#discussion_r128684229
 
 

 ##########
 File path: pulsar-client-cpp/lib/PartitionedConsumerImpl.cc
 ##########
 @@ -100,6 +101,29 @@ namespace pulsar {
         }
     }
 
+    void PartitionedConsumerImpl::receiveAsync(ReceiveCallback& callback) {
+        Message msg;
+
+        {
+            // fail the callback if consumer is closing or closed
+            Lock lock(mutex_);
+            if (state_ == Closing || state_ == Closed) {
+                callback(ResultAlreadyClosed, msg);
+                return;
+            }
+        }
+
+        Lock lock(pendingReceiveMutex_);
+        if(messages_.pop(msg, milliseconds(0))) {
+            lock.unlock();
+            unAckedMessageTrackerPtr_->add(msg.getMessageId());
+            callback(ResultOk, msg);
+        } else {
+            pendingReceives_.push(callback);
+            lock.unlock();
 
 Review comment:
   This unlock not required
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to