You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by if...@apache.org on 2020/05/26 23:14:21 UTC
[rocketmq-client-cpp] branch master updated: Fixed
TpsReportService::start
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 <yw...@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_; }