关于gtkmm中的多线程需要帮助

问题描述

我对线程处理不是很糟糕,我需要帮助,

我有一个带有进度条的gtkmm窗口,任务是在后台执行多个Shell脚本或Shell命令,并相应地更新进度条。我有一个

button->clicked_signal() {
         thread( [this] { worker->start() } ); 
}  


worker->start() {
      {
         lock_guard(mutex);         // as per i know to safely handle variables 
         progress = 0.0      
     }
      caller->notify();             // i found it on documentation that its for sending signal to window to refresh

   int ret = WEXITSTATUS(system("./my_shell_script with-args"));
  {
     lock_guard(mutex);
     progress = 0.4;
   }
  caller->notify();       // Simmilary i am handling more scripts
} 

问题是“完成”窗口处于冻结状态,直到过程完成。它仅发生在system()上; ,如果我使用loop()或其他函数,它将不会冻结。

我尝试了其他事情。

worker->executor() {
      int ret = WEXITSTATUS(system("./my_shell_script with-args"));
      {
         lock_guard(mutex);
         progress = 0.4;
       }
        // other executions
 }

worker->start() {
      thread  th1(&worker::executor,this);
      while(true) {
          caller->notify();
          if (stop) break;                             

      this_thread::sleep_for(chrono::milliseconds(120));     
      }

     th1.join();
     caller->notify();
} 

但仍在冻结。我在穿线方面很不好,

完整代码可在https://github.com/itsManjeet/opportunity.git分支(0.6.0)

获得

他们是做这件事的更好的方法

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)