forked from dsutanto/bytetrack-counter-cpp
Bug for new batches after 5 minutes
This commit is contained in:
1 parent
ccb1c89b12
commit
e6dc27398f
3 files changed
+4
-3
No files matched your search
+3
-3
@@ -191,10 +191,11 @@ void BatchStore::start_new_batch(const std::string& counting_date) {
|
||||
|
||||
void BatchStore::reset_batch_timer() {
|
||||
batch_timer_running_ = true;
|
||||
uint64_t gen = ++batch_timer_gen_;
|
||||
if (batch_timer_thread_.joinable()) batch_timer_thread_.detach();
|
||||
batch_timer_thread_ = std::thread([this]() {
|
||||
batch_timer_thread_ = std::thread([this, gen]() {
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
while (batch_timer_running_) {
|
||||
while (batch_timer_gen_ == gen && batch_timer_running_) {
|
||||
auto elapsed = std::chrono::duration_cast<std::chrono::seconds>(
|
||||
std::chrono::steady_clock::now() - start).count();
|
||||
if (elapsed >= batch_timeout_) {
|
||||
@@ -409,7 +410,6 @@ void BatchStore::start_cutoff_watcher() {
|
||||
void BatchStore::ping_activity() {
|
||||
std::lock_guard<std::mutex> lock(state_mutex_);
|
||||
if (!current_state_.is_null()) {
|
||||
current_state_["last_detection_time"] = now_iso();
|
||||
reset_batch_timer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ private:
|
||||
std::thread batch_timer_thread_;
|
||||
std::thread ignore_label_thread_;
|
||||
std::atomic<bool> batch_timer_running_{false};
|
||||
std::atomic<uint64_t> batch_timer_gen_{0};
|
||||
std::atomic<bool> ignore_label_active_{false};
|
||||
std::atomic<bool> shutdown_flag_{false};
|
||||
std::atomic<bool> ignore_batch_label_{false};
|
||||
|
||||
Reference in new issue
Block a user