shibd commented on code in PR #228:
URL: https://github.com/apache/pulsar-client-cpp/pull/228#discussion_r1151311569
##########
lib/ConsumerImpl.cc:
##########
@@ -649,10 +649,11 @@ void ConsumerImpl::executeNotifyCallback(Message& msg) {
void ConsumerImpl::notifyBatchPendingReceivedCallback(const
BatchReceiveCallback& callback) {
auto messages =
std::make_shared<MessagesImpl>(batchReceivePolicy_.getMaxNumMessages(),
batchReceivePolicy_.getMaxNumBytes());
- Message peekMsg;
- while (incomingMessages_.pop(peekMsg, std::chrono::milliseconds(0)) &&
messages->canAdd(peekMsg)) {
- messageProcessed(peekMsg);
- Message interceptMsg =
interceptors_->beforeConsume(Consumer(shared_from_this()), peekMsg);
+ Message msg;
+ while (incomingMessages_.peek(msg) && messages->canAdd(msg)) {
+ incomingMessages_.pop(msg);
Review Comment:
Make sense to me.
I added the `popIf` method on the queue. This avoids adding locks in
multiple places in the consumer(all pop, clear, peek call places). PTAL.
--
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]