BewareMyPower commented on code in PR #228:
URL: https://github.com/apache/pulsar-client-cpp/pull/228#discussion_r1147190108
##########
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:
Correctness is more important than performance. The race condition problem
is hard to analysis if it happened. We don't have to copy everything from the
Java client, including the bugs.
BTW, the `peek` and `pop` methods in C++ client already acquire the lock.
--
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]