diff --git a/tsl_aiplatform/reprocessing_module/save_snapshot_reprocessing.cpp b/tsl_aiplatform/reprocessing_module/save_snapshot_reprocessing.cpp index d6cdf6c..ec423dc 100644 --- a/tsl_aiplatform/reprocessing_module/save_snapshot_reprocessing.cpp +++ b/tsl_aiplatform/reprocessing_module/save_snapshot_reprocessing.cpp @@ -10,6 +10,7 @@ const bool DRAW_ON_IMG = false; vector compression_params; DWORD save_image_thread_process(LPVOID param); +bool bFinish = false; map index_to_algo_type = {{0, algorithm_type_t::HUMAN_SNAPSHOT}, {1, algorithm_type_t::NONMOTOR_VEHICLE_SNAPSHOT}, @@ -35,14 +36,18 @@ save_snapshot_reprocessing::save_snapshot_reprocessing() { _task_param_manager = task_param_manager::getInstance(); bFinish = false; - auto m_save_ss_thread = std::thread(save_image_thread_process, this); - m_save_ss_thread.detach(); + m_save_ss_thread = std::thread(save_image_thread_process, this); + // m_save_ss_thread.detach(); } -// 释放资源 -void save_snapshot_reprocessing::save_snapshot_reprocessing_release() { +save_snapshot_reprocessing::~save_snapshot_reprocessing(){ // 结束线程 bFinish = true; + m_save_ss_thread.join(); +} + +// 释放资源 +void save_snapshot_reprocessing::save_snapshot_reprocessing_release() { std::unique_lock l(waitforsave_image_queue_mutex); diff --git a/tsl_aiplatform/reprocessing_module/save_snapshot_reprocessing.h b/tsl_aiplatform/reprocessing_module/save_snapshot_reprocessing.h index 2432af1..a8a2590 100644 --- a/tsl_aiplatform/reprocessing_module/save_snapshot_reprocessing.h +++ b/tsl_aiplatform/reprocessing_module/save_snapshot_reprocessing.h @@ -55,6 +55,7 @@ class save_snapshot_reprocessing : public base_reprocessing_unit { public: save_snapshot_reprocessing(); + ~save_snapshot_reprocessing(); void save_snapshot_reprocessing_release(); void add_newtask(const string taskid); @@ -82,7 +83,7 @@ public: // map save_snapshot_info_count; // debug by zsh mutable std::mutex waitforchange_taskid_mutex; - bool bFinish{false}; + std::thread m_save_ss_thread; #ifdef POST_USE_RABBITMQ callback_t callback_;