From 5c912c70e9333298ff48f7ea15424f72ca977b99 Mon Sep 17 00:00:00 2001 From: Fu Juntang <StrongTiger_001@163.com> Date: 星期五, 17 九月 2021 09:43:55 +0800 Subject: [PATCH] Add the heartbeat logic feature. --- src/socket/bus_server_socket.h | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 51 insertions(+), 8 deletions(-) diff --git a/src/socket/bus_server_socket.h b/src/socket/bus_server_socket.h index d475f02..ba6ebe8 100644 --- a/src/socket/bus_server_socket.h +++ b/src/socket/bus_server_socket.h @@ -3,7 +3,7 @@ #include "usg_common.h" #include "shm_socket.h" #include "shm_allocator.h" -#include "mem_pool.h" +#include "shm_mm.h" #include "hashtable.h" #include "sem_util.h" #include "logger_factory.h" @@ -18,6 +18,43 @@ typedef std::set<int, std::less<int>, SHM_STL_Allocator<int> > SHMKeySet; typedef std::map<SHMString, SHMKeySet *, std::less<SHMString>, SHM_STL_Allocator<std::pair<const SHMString, SHMKeySet *> > > SHMTopicSubMap; +typedef struct _LinkNode +{ + int data; + int data_fix; + int count; + + _LinkNode *next; +} LinkNode; + +class list +{ + +private: + + LinkNode *head; + +public: + + list() {head = NULL;}; + + void Insert(int aDate, int bDate); + + void Delete(int Data); + + int dataFixGet(int data); + + int dataGet(int data); + + void dataSet(int data, int val); + + int NodeNum(void); + + int nodeGet(int index); + + LinkNode *getHead() {return head;}; + +}; class BusServerSocket { private: @@ -27,15 +64,18 @@ SHMTopicSubMap *topic_sub_map; private: + int destroy(); void _proxy_sub( char *topic, int key); - void _proxy_pub( char *topic, void *buf, size_t size, int key); - void *run_pubsub_proxy(); - int parse_pubsub_topic(char *str, size_t size, char **_action, char **_topic, size_t *head_len ); - + void _proxy_pub( char *topic, char *buf, size_t size, int key); + int _run_proxy_(); + // int parse_pubsub_topic(char *str, size_t size, char **_action, char **_topic, size_t *head_len ); + void _proxy_desub( char *topic, int key); void _proxy_desub_all(int key); - static void foreach_subscripters(std::function<void(SHMKeySet *, int)> cb); + void _proxy_reg(const char *topic, size_t topic_size, const char *content, size_t content_size, int key, int flag); + + static void foreach_subscripters(std::function<void(SHMKeySet *, int)> cb); // static bool include_in_keys(int key, int keys[], size_t length); public: @@ -64,6 +104,7 @@ * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ int start(); + int get_data(int val); /** * 鍋滄bus @@ -71,14 +112,16 @@ * @return 0 鎴愬姛锛� 鍏朵粬鍊� 澶辫触鐨勯敊璇爜 */ int stop(); - - + int check_proc(int val, const void *buf, int len, void **buf_ret, int *len_ret, \ + const struct timespec *timeout, const int flag); + void remove_proc(int val); /** * 鑾峰彇soket key */ int get_key() ; + void _data_remove(int val1, int val2); }; -- Gitblit v1.8.0