conn_manager.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * conn_manager.h
  3. *
  4. * Created on: Sep 15, 2017
  5. * Author: root
  6. */
  7. #ifndef CONN_MANAGER_H_
  8. #define CONN_MANAGER_H_
  9. #include "common.h"
  10. #include "log.h"
  11. extern int disable_conv_clear;
  12. struct conn_manager_t //TODO change map to unordered map
  13. {
  14. //typedef hash_map map;
  15. unordered_map<u64_t,u32_t> u64_to_fd; //conv and u64 are both supposed to be uniq
  16. unordered_map<u32_t,u64_t> fd_to_u64;
  17. unordered_map<u32_t,u64_t> fd_last_active_time;
  18. unordered_map<u32_t,u64_t>::iterator clear_it;
  19. unordered_map<u32_t,u64_t>::iterator it;
  20. unordered_map<u32_t,u64_t>::iterator old_it;
  21. //void (*clear_function)(uint64_t u64) ;
  22. long long last_clear_time;
  23. list<int> clear_list;
  24. conn_manager_t();
  25. ~conn_manager_t();
  26. int get_size();
  27. void rehash();
  28. void clear();
  29. int exist_fd(u32_t fd);
  30. int exist_u64(u64_t u64);
  31. u32_t find_fd_by_u64(u64_t u64);
  32. u64_t find_u64_by_fd(u32_t fd);
  33. int update_active_time(u32_t fd);
  34. int insert_fd(u32_t fd,u64_t u64);
  35. int erase_fd(u32_t fd);
  36. void check_clear_list();
  37. int clear_inactive();
  38. int clear_inactive0();
  39. };
  40. #endif /* CONN_MANAGER_H_ */