RobertIndie commented on code in PR #309:
URL: 
https://github.com/apache/pulsar-client-node/pull/309#discussion_r1159362567


##########
src/Consumer.cc:
##########
@@ -82,9 +96,15 @@ void MessageListener(pulsar_consumer_t *rawConsumer, 
pulsar_message_t *rawMessag
     return;
   }
 
-  MessageListenerProxyData *dataPtr = new MessageListenerProxyData(cMessage, 
consumer);
+  std::promise<void> promise;
+  std::future<void> future = promise.get_future();
+  MessageListenerProxyData *dataPtr =
+      new MessageListenerProxyData(cMessage, consumer, [&]() { 
promise.set_value(); });
   listenerCallback->callback.BlockingCall(dataPtr, MessageListenerProxy);
   listenerCallback->callback.Release();
+
+  future.wait();
+  delete dataPtr;

Review Comment:
   The `BlockingCall` only accepts the raw pointer. FYI: 
https://github.com/nodejs/node-addon-api/blob/main/doc/threadsafe_function.md#blockingcall--nonblockingcall



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