Commit 940c81797b2f040b70cc11f5d117018102d11b8d

Authored by Hu Chunming
1 parent 682bbe39

代码优化

test/main.cpp
@@ -114,7 +114,7 @@ void init_mq_conn(void *handle) { @@ -114,7 +114,7 @@ void init_mq_conn(void *handle) {
114 } 114 }
115 #endif 115 #endif
116 116
117 -const char* ipc_url = "/home/cmhu/tongtu/tsl_aiplatform_project_with_screenshot/data/duan1.avi"; 117 +const char* ipc_url = "/data/cmhu/data2/duan1.avi";
118 118
119 void set_ipc_url(task_param &tparam, const algorithm_type_t &algor_type) { 119 void set_ipc_url(task_param &tparam, const algorithm_type_t &algor_type) {
120 120
tsl_aiplatform/ai_platform/MultiSourceProcess.cpp
@@ -1280,6 +1280,7 @@ void CMultiSourceProcess::CloseAllTask(){ @@ -1280,6 +1280,7 @@ void CMultiSourceProcess::CloseAllTask(){
1280 1280
1281 pthread_join(m_gpuProcessthread,0); 1281 pthread_join(m_gpuProcessthread,0);
1282 1282
  1283 + // 待解码线程和算法处理线程都结束后再清理数据队列
1283 m_QueueMtx.lock(); 1284 m_QueueMtx.lock();
1284 for (auto iter = m_RgbDataList.begin(); iter!=m_RgbDataList.end(); ){ 1285 for (auto iter = m_RgbDataList.begin(); iter!=m_RgbDataList.end(); ){
1285 GpuRgbMemory* gpuMem = *iter; 1286 GpuRgbMemory* gpuMem = *iter;
tsl_aiplatform/reprocessing_module/save_snapshot_reprocessing.cpp
@@ -34,12 +34,16 @@ save_snapshot_reprocessing::save_snapshot_reprocessing() { @@ -34,12 +34,16 @@ save_snapshot_reprocessing::save_snapshot_reprocessing() {
34 _snapshot_reprocessing = snapshot_reprocessing::getInstance(); 34 _snapshot_reprocessing = snapshot_reprocessing::getInstance();
35 _task_param_manager = task_param_manager::getInstance(); 35 _task_param_manager = task_param_manager::getInstance();
36 36
  37 + bFinish = false;
37 auto m_save_ss_thread = std::thread(save_image_thread_process, this); 38 auto m_save_ss_thread = std::thread(save_image_thread_process, this);
38 m_save_ss_thread.detach(); 39 m_save_ss_thread.detach();
39 } 40 }
40 41
41 // 释放资源 42 // 释放资源
42 void save_snapshot_reprocessing::save_snapshot_reprocessing_release() { 43 void save_snapshot_reprocessing::save_snapshot_reprocessing_release() {
  44 + // 结束线程
  45 + bFinish = true;
  46 +
43 std::unique_lock<std::mutex> l(waitforsave_image_queue_mutex); 47 std::unique_lock<std::mutex> l(waitforsave_image_queue_mutex);
44 48
45 while (!waitforsave_image_queue.empty()) { 49 while (!waitforsave_image_queue.empty()) {
@@ -322,6 +326,10 @@ DWORD save_image_thread_process(LPVOID param) { @@ -322,6 +326,10 @@ DWORD save_image_thread_process(LPVOID param) {
322 save_snapshot_reprocessing *pThreadParam = (save_snapshot_reprocessing *)param; 326 save_snapshot_reprocessing *pThreadParam = (save_snapshot_reprocessing *)param;
323 327
324 while (true) { 328 while (true) {
  329 + if (bFinish){
  330 + break;
  331 + }
  332 +
325 std::unique_lock<std::mutex> l(pThreadParam->waitforsave_image_queue_mutex); 333 std::unique_lock<std::mutex> l(pThreadParam->waitforsave_image_queue_mutex);
326 std::unique_lock<std::mutex> l_taskid(pThreadParam->waitforchange_taskid_mutex); 334 std::unique_lock<std::mutex> l_taskid(pThreadParam->waitforchange_taskid_mutex);
327 if (!pThreadParam->waitforsave_image_queue.empty()) { 335 if (!pThreadParam->waitforsave_image_queue.empty()) {
tsl_aiplatform/reprocessing_module/save_snapshot_reprocessing.h
@@ -82,6 +82,8 @@ public: @@ -82,6 +82,8 @@ public:
82 // map<OBJ_KEY, int> save_snapshot_info_count; // debug by zsh 82 // map<OBJ_KEY, int> save_snapshot_info_count; // debug by zsh
83 mutable std::mutex waitforchange_taskid_mutex; 83 mutable std::mutex waitforchange_taskid_mutex;
84 84
  85 + bool bFinish{false};
  86 +
85 #ifdef POST_USE_RABBITMQ 87 #ifdef POST_USE_RABBITMQ
86 callback_t callback_; 88 callback_t callback_;
87 std::shared_ptr<mq::post_rabbitmq_reprocessing> rbmq_handler_; 89 std::shared_ptr<mq::post_rabbitmq_reprocessing> rbmq_handler_;