shibd commented on code in PR #71:
URL: https://github.com/apache/pulsar-client-cpp/pull/71#discussion_r1007591353
##########
lib/ConsumerImpl.cc:
##########
@@ -319,6 +320,31 @@ void ConsumerImpl::unsubscribeAsync(ResultCallback
originalCallback) {
}
}
+void ConsumerImpl::triggerCheckExpiredChunkedTimer() {
+ checkExpiredChunkedTimer_->expires_from_now(
+
boost::posix_time::milliseconds(expireTimeOfIncompleteChunkedMessageMs_));
+ std::weak_ptr<ConsumerImplBase> weakSelf{shared_from_this()};
+ checkExpiredChunkedTimer_->async_wait([this, weakSelf](const
boost::system::error_code& ec) -> void {
Review Comment:
Here still caught `this`, You can refer:
``` c++
std::weak_ptr<ConsumerImpl> weakSelf{get_shared_this_ptr()};
checkExpiredChunkedTimer_->async_wait([weakSelf](const
boost::system::error_code& ec) -> void {
auto self = weakSelf.lock();
if (!self || ec) {
return;
}
Lock lock(self->chunkProcessMutex_);
long currentTimeMs = TimeUtils::currentTimeMillis();
self->chunkedMessageCache_.removeOldestValuesIf(
[self, ¤tTimeMs](const std::string& uuid, const
ChunkedMessageCtx& ctx) -> bool {
return currentTimeMs > ctx.getReceivedTimeMs() +
self->expireTimeOfIncompleteChunkedMessageMs_;
});
self->triggerCheckExpiredChunkedTimer();
return;
});
```
##########
lib/ConsumerImpl.cc:
##########
@@ -319,6 +320,27 @@ void ConsumerImpl::unsubscribeAsync(ResultCallback
originalCallback) {
}
}
+void ConsumerImpl::triggerCheckExpiredChunkedTimer() {
+ checkExpiredChunkedTimer_ = executor_->createDeadlineTimer();
+ checkExpiredChunkedTimer_->expires_from_now(
+
boost::posix_time::milliseconds(expireTimeOfIncompleteChunkedMessageMs_));
+ checkExpiredChunkedTimer_->async_wait([this](const
boost::system::error_code& ec) -> void {
+ if (ec) {
+ LOG_DEBUG(getName() << " Check expired chunked messages was failed
or cancelled, code[" << ec
+ << "].");
+ return;
+ }
+ Lock lock(chunkProcessMutex_);
+ long currentTimeMs = TimeUtils::currentTimeMillis();
+ chunkedMessageCache_.removeOldestValuesIf(
+ [this, ¤tTimeMs](const std::string& uuid, const
ChunkedMessageCtx& ctx) -> bool {
Review Comment:
Oh, You still caught `this` above.
--
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]