BewareMyPower commented on code in PR #16943:
URL: https://github.com/apache/pulsar/pull/16943#discussion_r951127633
##########
pulsar-client-cpp/lib/ConsumerImpl.cc:
##########
@@ -1326,8 +1336,26 @@ void
ConsumerImpl::getLastMessageIdAsync(BrokerGetLastMessageIdCallback callback
callback(ResultUnsupportedVersionError, MessageId());
}
} else {
- LOG_ERROR(getName() << " Client Connection not ready for Consumer");
- callback(ResultNotConnected, MessageId());
+ TimeDuration next = std::min(remainTime, backoff->next());
+ if (next.total_milliseconds() <= 0) {
+ LOG_ERROR(getName() << " Client Connection not ready for
Consumer");
+ callback(ResultNotConnected, MessageId());
+ return;
+ }
+ remainTime -= next;
+
+ timer->expires_from_now(next);
+
+ timer->async_wait([this, backoff, remainTime, timer, next,
+ callback](const boost::system::error_code& ec) ->
void {
Review Comment:
Your reference is an example. `self` is what `shared_from_this()` returns,
this lambda captures `self` by value so that the reference count will increase
by one. After the lambda ends, the reference count will decrease by one, so the
object keeps valid (refcnt is always > 0) during the lifetime of the lambda.
--
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]