From 45e00aca28504b27f3ad6b4abf364c3d57f34510 Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期一, 22 二月 2021 14:05:28 +0800 Subject: [PATCH] lock free queue --- src/net/net_mod_socket.cpp | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/net/net_mod_socket.cpp b/src/net/net_mod_socket.cpp index 8c1465d..e689cea 100644 --- a/src/net/net_mod_socket.cpp +++ b/src/net/net_mod_socket.cpp @@ -40,14 +40,18 @@ NetModSocket::~NetModSocket() { - int s; + // int s; // delete gpool; // s = pthread_mutex_destroy(&sendMutex); - if(s != 0) { - err_exit(s, "shm_close_socket"); - } + // if(s != 0) { + // err_exit(s, "shm_socket_close"); + // } } + +int NetModSocket::stop() { + return shmModSocket.stop(); +} /** * 缁戝畾绔彛鍒皊ocket, 濡傛灉涓嶇粦瀹氬垯绯荤粺鑷姩鍒嗛厤涓�涓� @@ -304,22 +308,22 @@ } -int NetModSocket::pub(net_node_t *node_arr, int arrlen, char *topic, int topic_size, void *content, int content_size) { +int NetModSocket::pub(net_node_t *node_arr, int arrlen, const char *topic, int topic_size, const void *content, int content_size) { return _pub_(node_arr, arrlen, topic, topic_size, content, content_size, -1); } -int NetModSocket::pub_nowait(net_node_t *node_arr, int arrlen, char *topic, int topic_size, void *content, int content_size) { +int NetModSocket::pub_nowait(net_node_t *node_arr, int arrlen, const char *topic, int topic_size, const void *content, int content_size) { return _pub_(node_arr, arrlen, topic, topic_size, content, content_size, 0); } -int NetModSocket::pub_timeout(net_node_t *node_arr, int arrlen, char *topic, int topic_size, void *content, int content_size, int msec ) { +int NetModSocket::pub_timeout(net_node_t *node_arr, int arrlen, const char *topic, int topic_size, const void *content, int content_size, int msec ) { return _pub_(node_arr, arrlen, topic, topic_size, content, content_size, msec); } // int pub(char *topic, int topic_size, void *content, int content_size, int port); -int NetModSocket::_pub_(net_node_t *node_arr, int arrlen, char *topic, int topic_size, void *content, +int NetModSocket::_pub_(net_node_t *node_arr, int arrlen, const char *topic, int topic_size, const void *content, int content_size, int msec) { int i, connfd; net_node_t *node; @@ -596,7 +600,7 @@ //====================================================================================== int NetModSocket::write_request(int clientfd, net_mod_request_head_t &request_head, - void *content_buf, int content_size, void *topic_buf, int topic_size) { + const void *content_buf, int content_size, const void *topic_buf, int topic_size) { int buf_size; char *buf; -- Gitblit v1.8.0