You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/03/14 06:37:58 UTC

[GitHub] [pulsar-client-node] Matt-Esch commented on a change in pull request #200: convert worker threads to async functions

Matt-Esch commented on a change in pull request #200:
URL: https://github.com/apache/pulsar-client-node/pull/200#discussion_r825628138



##########
File path: src/Consumer.cc
##########
@@ -79,144 +81,131 @@ void MessageListener(pulsar_consumer_t *cConsumer, pulsar_message_t *cMessage, v
   listenerCallback->callback.Release();
 }
 
-void Consumer::SetCConsumer(std::shared_ptr<CConsumerWrapper> cConsumer) { this->wrapper = cConsumer; }
-void Consumer::SetListenerCallback(ListenerCallback *listener) {
+void Consumer::SetCConsumer(std::shared_ptr<pulsar_consumer_t> cConsumer) { this->cConsumer = cConsumer; }
+void Consumer::SetListenerCallback(MessageListenerCallback *listener) {
   if (listener) {
+    // Pass consumer as argument
+    listener->consumer = this;
+  }
+
+  if (this->listener == nullptr) {
     // Maintain reference to consumer, so it won't get garbage collected
     // since, when we have a listener, we don't have to maintain reference to consumer (in js code)
     this->Ref();

Review comment:
       I think this was purely to make sure that the ref count is balanced. So if we set the listener 10 times, we don't Ref the Consumer more than once, as there is only one corresponding Unref in `Consumer::Cleanup()`.




-- 
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: dev-unsubscribe@pulsar.apache.org

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