Sectorpower.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * @Description:
  3. * @Version: 1.0
  4. * @Autor: lishengyin
  5. * @Date: 2022-04-02 14:19:36
  6. * @LastEditors: lishengyin
  7. * @LastEditTime: 2022-04-18 17:25:25
  8. */
  9. #ifndef __SECTORPOWER_HPP_
  10. #define __SECTORPOWER_HPP_
  11. #include <iostream>
  12. #include "ins_base.hpp"
  13. #include <mutex>
  14. #include <thread>
  15. #include <condition_variable>
  16. #include <queue>
  17. #include <vector>
  18. #include "Util/logger.h"
  19. #include "Util/NoticeCenter.h"
  20. #include "TaskCenter.hpp"
  21. using namespace std;
  22. using namespace toolkit;
  23. namespace ins
  24. {
  25. /**
  26. * @description: sectorPower 权力部门
  27. */
  28. class Sectorpower:public Module
  29. {
  30. private:
  31. Sectorpower();
  32. public:
  33. using Ptr = std::shared_ptr<Sectorpower>;
  34. ~Sectorpower(){this->Destroy();}
  35. /**
  36. * @description: 获取ptr
  37. * @param {*}
  38. * @return {*}
  39. */
  40. static std::shared_ptr<Sectorpower> getPtr();
  41. /**
  42. * @description: 初始化
  43. * @param {*}
  44. * @return {*}
  45. */
  46. int8_t Init() override;
  47. /**
  48. * @description: 释放
  49. * @param {*}
  50. * @return {*}
  51. */
  52. void Destroy() override;
  53. /**
  54. * @description: 是否正常
  55. * @param {*}
  56. * @return {*}
  57. */
  58. bool isNormally() override{
  59. return true;
  60. }
  61. /**
  62. * @description: 检查任务
  63. * @param {*}
  64. * @return {*}
  65. */
  66. bool reviewTask(ins::InsTask::Ptr& task);
  67. /**
  68. * @description: 获取工作流任务
  69. * @param {*}
  70. * @return {*}
  71. */
  72. InsTask::Ptr getWorkflowTask(InsPacket::Ptr pack);
  73. /**
  74. * @description: 业务入队
  75. * @param {*}
  76. * @return {*}
  77. */
  78. int8_t enqueue(InsPacket::Ptr packet);
  79. protected:
  80. mutex m_mutex;
  81. condition_variable condition;
  82. bool stop = false;
  83. vector<thread> workers;
  84. queue<InsPacket::Ptr> Transactions;
  85. };
  86. } // namespace name
  87. #endif