rdhabalia commented on a change in pull request #577: CPP add receiveAsync API
URL: https://github.com/apache/incubator-pulsar/pull/577#discussion_r128063623
##########
File path: pulsar-client-cpp/lib/PartitionedConsumerImpl.h
##########
@@ -79,6 +80,7 @@ namespace pulsar {
typedef std::vector<ConsumerImplPtr> ConsumerList;
ConsumerList consumers_;
boost::mutex mutex_;
+ boost::mutex pendingReceiveMutex_;
Review comment:
`pendingReceiveMutex_` is a mutex which requires to sync
`pendingReceives-queue` and `incomingMessages-queue` together to make sure
message-queue is empty while adding into pending-queue.
`mutex_` will not work here for example:
-
[receive()](https://github.com/apache/incubator-pulsar/blob/master/pulsar-client-cpp/lib/PartitionedConsumerImpl.cc#L67)
is a blocking call which takes locks on `mutext_` until message is received
- now, if we use the same `mutex_` on
[message-received](https://github.com/rdhabalia/pulsar/blob/12dec47295d9a2b896c4b46bb5e7cb37ddd8fbf3/pulsar-client-cpp/lib/PartitionedConsumerImpl.cc#L338)
then it will create a deadlock.
----------------------------------------------------------------
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