12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- //
- // Created by zx on 2020/8/26.
- //
- #include "process_task.h"
- Process_task::Process_task(unsigned int terminal_id,message::Car_info car_info)
- :m_publish_statu_thread(nullptr)
- {
- m_terminor_id=terminal_id;
- m_car_info=car_info;
- }
- Process_task::~Process_task()
- {
- //退出线程
- m_publish_exit_condition.set_pass_ever(true);
- if(m_publish_statu_thread!= nullptr)
- {
- if(m_publish_statu_thread->joinable())
- {
- m_publish_statu_thread->join();
- }
- delete m_publish_statu_thread;
- m_publish_statu_thread=nullptr;
- }
- }
- /*
- * 取消任务
- */
- void Process_task::Cancel()
- {
- m_current_step_type= message::eBackComplete;
- m_cancel_condition.set_pass_ever(true);
- tq::BaseTask::Cancel();
- }
- /*
- * 发布进度
- */
- void Process_task::publish_thread_func(Process_task* ptask)
- {
- if(ptask)
- {
- //未收到退出信号
- while(false==ptask->m_publish_exit_condition.wait_for_ex(std::chrono::milliseconds(100))) {
- ptask->publish_step_status();
- }
- }
- }
- /*
- * 任务是否取消
- */
- bool Process_task::is_canceled()
- {
- return m_cancel_condition.wait_for_millisecond(1);
- }
|