/* * @Description: * @Version: 1.0 * @Autor: lishengyin * @Date: 2022-04-07 17:19:16 * @LastEditors: lishengyin * @LastEditTime: 2022-04-15 11:26:20 */ #ifndef __TASHCENTER_HPP_ #define __TASHCENTER_HPP_ #include "ins_base.hpp" #include #include #include #include #include using namespace std; namespace ins { class TaskCenter:public Module { private: TaskCenter(); public: using Ptr = std::shared_ptr; ~TaskCenter(){this->Destroy();} /** * @description: 获取实例 * @param {*} * @return {*} */ static std::shared_ptr getPtr(); /** * @description: 创建实例 * @param {*} * @return {*} */ static std::shared_ptr CreateNew(); /** * @description: 初始化 * @param {*} * @return {*} */ int8_t Init() override; /** * @description: 释放资源 * @param {*} * @return {*} */ void Destroy() override; /** * @description: 是否正常 * @param {*} * @return {*} */ bool isNormally() override{ return true; } /** * @description: 任务入队 * @param {Ptr&} task 任务 * @return {*} */ int8_t enqueue(ins::InsTask::Ptr& task); /** * @description: 处理数据包 * @param {*} * @return {*} */ int8_t ProcessingPacket(InsPacket::Ptr& pack); private: queue async_Tasks; vector workers; condition_variable condition; mutex m_mutex; bool stop = false; }; } // namespace ins #endif