123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- /*
- * @Description:
- * @Version: 1.0
- * @Autor: lishengyin
- * @Date: 2022-04-02 14:19:36
- * @LastEditors: lishengyin
- * @LastEditTime: 2022-06-15 10:55:46
- */
- #ifndef __SECTORPOWER_HPP_
- #define __SECTORPOWER_HPP_
- #include <iostream>
- #include "ins_base.hpp"
- #include <mutex>
- #include <thread>
- #include <condition_variable>
- #include <queue>
- #include <vector>
- #include "Util/logger.h"
- #include "Util/NoticeCenter.h"
- #include "TaskCenter.hpp"
- using namespace std;
- using namespace toolkit;
- namespace ins
- {
- /**
- * @description: sectorPower 权力部门
- */
- class Sectorpower:public Module
- {
- private:
- Sectorpower();
-
- public:
- using Ptr = std::shared_ptr<Sectorpower>;
- ~Sectorpower(){this->Destroy();}
- /**
- * @description: 获取ptr
- * @param {*}
- * @return {*}
- */
- static std::shared_ptr<Sectorpower> getPtr();
- /**
- * @description: 初始化
- * @param {*}
- * @return {*}
- */
- int8_t Init() override;
- /**
- * @description: 释放
- * @param {*}
- * @return {*}
- */
- void Destroy() override;
- /**
- * @description: 是否正常
- * @param {*}
- * @return {*}
- */
- bool isNormally() override{
- return true;
- }
- /**
- * @description: 检查任务
- * @param {*}
- * @return {*}
- */
- bool reviewTask(ins::InsTask::Ptr& task);
- /**
- * @description: 获取工作流任务
- * @param {*}
- * @return {*}
- */
- InsTask::Ptr getWorkflowTask(InsPacket::Ptr pack);
- /**
- * @description: 业务入队
- * @param {*}
- * @return {*}
- */
- int8_t enqueue(InsPacket::Ptr packet);
- /**
- * @description: 使能
- * @return {*}
- */
- bool getEnable(){
- return Enable;
- }
-
- /**
- * @description: 设置使能
- * @param {bool} result
- * @return {*}
- */
- bool setEnable(bool result){
- Enable = result;
- return true;
- }
-
- protected:
- mutex m_mutex;
- condition_variable condition;
- bool stop = false;
- vector<thread> workers;
- queue<InsPacket::Ptr> Transactions;
- bool Enable = false;
- };
- } // namespace name
- #endif
|