rocketmq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ifplu...@apache.org
Subject [rocketmq-client-cpp] branch master updated: Fixed TpsReportService::start
Date Tue, 26 May 2020 23:14:21 GMT
This is an automated email from the ASF dual-hosted git repository.

ifplusor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-client-cpp.git


The following commit(s) were added to refs/heads/master by this push:
     new b1160b9  Fixed TpsReportService::start
b1160b9 is described below

commit b1160b902d93ceacf3056736d585612bd7bb96a4
Author: James Yin <ywhjames@hotmail.com>
AuthorDate: Mon May 25 10:00:27 2020 +0800

    Fixed TpsReportService::start
---
 example/common.h | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/example/common.h b/example/common.h
index 58d4b4e..065b759 100644
--- a/example/common.h
+++ b/example/common.h
@@ -66,22 +66,24 @@ class RocketmqSendAndConsumerArgs {
 class TpsReportService {
  public:
   TpsReportService() : tps_interval_(1), quit_flag_(false), tps_count_(0) {}
-  void start() {
-    if (tps_thread_ == NULL) {
-      std::cout << "tps_thread_ is null" << std::endl;
-      return;
-    }
-    tps_thread_.reset(new std::thread(std::bind(&TpsReportService::TpsReport, this)));
-  }
 
   ~TpsReportService() {
     quit_flag_.store(true);
-    if (tps_thread_ == NULL) {
+    if (tps_thread_ == nullptr) {
       std::cout << "tps_thread_ is null" << std::endl;
       return;
     }
-    if (tps_thread_->joinable())
+    if (tps_thread_->joinable()) {
       tps_thread_->join();
+    }
+  }
+
+  void start() {
+    if (tps_thread_ != nullptr) {
+      std::cout << "tps_thread_ is not null" << std::endl;
+      return;
+    }
+    tps_thread_.reset(new std::thread(std::bind(&TpsReportService::TpsReport, this)));
   }
 
   void Increment() { ++tps_count_; }


Mime
View raw message