shibd commented on code in PR #13079:
URL: https://github.com/apache/pulsar/pull/13079#discussion_r949758043


##########
pulsar-client-cpp/lib/stats/ConsumerStatsImpl.cc:
##########
@@ -30,58 +31,76 @@ ConsumerStatsImpl::ConsumerStatsImpl(std::string 
consumerStr, ExecutorServicePtr
     : consumerStr_(consumerStr),
       executor_(executor),
       timer_(executor_->createDeadlineTimer()),
-      statsIntervalInSeconds_(statsIntervalInSeconds) {
-    
timer_->expires_from_now(boost::posix_time::seconds(statsIntervalInSeconds_));
-    timer_->async_wait(std::bind(&pulsar::ConsumerStatsImpl::flushAndReset, 
this, std::placeholders::_1));
+      statsIntervalInSeconds_(statsIntervalInSeconds),
+      callbackLock_(std::make_shared<stats::AsyncCallbackLock>()) {
+    scheduleReport();
 }
 
-ConsumerStatsImpl::ConsumerStatsImpl(const ConsumerStatsImpl& stats)
-    : consumerStr_(stats.consumerStr_),
-      numBytesRecieved_(stats.numBytesRecieved_),
-      receivedMsgMap_(stats.receivedMsgMap_),
-      ackedMsgMap_(stats.ackedMsgMap_),
-      totalNumBytesRecieved_(stats.totalNumBytesRecieved_),
-      totalReceivedMsgMap_(stats.totalReceivedMsgMap_),
-      totalAckedMsgMap_(stats.totalAckedMsgMap_),
-      statsIntervalInSeconds_(stats.statsIntervalInSeconds_) {}
-
 void ConsumerStatsImpl::flushAndReset(const boost::system::error_code& ec) {
     if (ec) {

Review Comment:
   40~43 lines can be moved to 82 lines. 



-- 
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]

Reply via email to