Skip to content

Commit

Permalink
Fixed TpsReportService::start
Browse files Browse the repository at this point in the history
  • Loading branch information
ifplusor committed May 26, 2020
1 parent cb4599c commit b1160b9
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions example/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_; }
Expand Down

0 comments on commit b1160b9

Please sign in to comment.