measure_excutor.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //
  2. // Created by zx on 2020/6/18.
  3. //
  4. #ifndef NNXX_TESTS_LOCATE_COMMUNICATOR_H
  5. #define NNXX_TESTS_LOCATE_COMMUNICATOR_H
  6. #include <mutex>
  7. #include "message_communicator.h"
  8. #include "measure_message.pb.h"
  9. #include "thread_safe_map.h"
  10. /*
  11. * 注册消息的比较函数,用于重载==与<符号,使其可以用作map中的key
  12. */
  13. class Measure_excutor: public Singleton<Measure_excutor>
  14. {
  15. friend Singleton<Measure_excutor>;
  16. public:
  17. virtual ~Measure_excutor();
  18. Error_manager locate_request(message::Measure_request_msg& request,
  19. message::Measure_response_msg& result,Thread_condition& cancel_condition);
  20. Error_manager consume_msg(Communication_message* p_msg);
  21. /*
  22. * 提前取消请求
  23. */
  24. Error_manager cancel_request(message::Measure_request_msg& request);
  25. Error_manager check_statu(int terminal_id);
  26. protected:
  27. Measure_excutor();
  28. protected:
  29. thread_safe_map<std::string,message::Measure_response_msg> m_response_table;
  30. thread_safe_map<int ,message::Measure_status_msg > m_measure_statu_msg_map;
  31. thread_safe_map<int ,std::chrono::system_clock::time_point> m_statu_recv_time_map;
  32. };
  33. #endif //NNXX_TESTS_LOCATE_COMMUNICATOR_H