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

---
 test_net_socket/test_net_mod_socket.cpp |  199 ++++++++++++++++++++++++++-----------------------
 1 files changed, 105 insertions(+), 94 deletions(-)

diff --git a/test_net_socket/test_net_mod_socket.cpp b/test_net_socket/test_net_mod_socket.cpp
index e036682..ab46f31 100644
--- a/test_net_socket/test_net_mod_socket.cpp
+++ b/test_net_socket/test_net_mod_socket.cpp
@@ -75,6 +75,11 @@
 	}
 }
 
+void start_resycle() {
+  shm_mm_wrapper_start_resycle();
+}
+
+
 // 鎵撳嵃鎺ュ彈鍒扮殑璁㈤槄娑堟伅
 void *print_sub_msg(void *sockt) {
   pthread_detach(pthread_self());
@@ -370,7 +375,8 @@
   double difftime = end.tv_sec * 1000000 + end.tv_usec - (start.tv_sec * 1000000 + start.tv_usec);
   long diffsec = (long) (difftime/1000000);
   long diffusec = difftime - diffsec*1000000;
-  fprintf(stderr,"鍙戦�佹暟鐩�: %ld, 鐢ㄦ椂: (%ld sec %ld usec), 骞冲潎: %f\n", total, diffsec, diffusec, difftime/total );
+  fprintf(stderr,"鍙戦�佹暟鐩�:%ld, 鎴愬姛鏁扮洰: %ld, 鐢ㄦ椂: (%ld sec %ld usec), 骞冲潎: %f\n", 
+    SCALE*node_arr_size, total, diffsec, diffusec, difftime/total );
   // fflush(stdout);
  
 }
@@ -518,99 +524,6 @@
     LoggerFactory::getLogger()->debug( "pub to  %d nodes\n", n);
   }
   net_mod_socket_close(client);
-}
-
-
-int main(int argc, char *argv[]) {
-	shm_mm_wrapper_init(512);
- 
-  argument_t opt = parse_args(argc, argv);
-
- // port = atoi(argv[2]);
-	 
-  if(opt.fun == NULL) {
-    usage(argv[0]);
-    exit(1);
-  }
-
-	if (strcmp("start_net_proxy", opt.fun) == 0 ) {
-    if(opt.port == 0) {
-      usage(argv[0]);
-      exit(1);
-    }
-    start_net_proxy(opt);
-    
-  }
-  else if (strcmp("start_bus_server", opt.fun) == 0) {
-     
-    start_bus_server(opt);
-  }
-  else if (strcmp("start_reply", opt.fun) == 0) {
-    if(opt.key == 0) {
-      usage(argv[0]);
-      exit(1);
-    }
-    start_reply(opt.key);
-  }
-  else if (strcmp("start_net_client", opt.fun) == 0) {
-    if(opt.sendlist == 0) {
-      fprintf(stderr, "Missing sendlist .\n");
-      usage(argv[0]);
-      exit(1);
-    }
-    if(opt.publist == 0) {
-      fprintf(stderr, "Missing publist.\n");
-      usage(argv[0]);
-      exit(1);
-    }
-    start_net_client(opt.sendlist, opt.publist);
-  }
-  else if (strcmp("one_sendto_many", opt.fun) == 0) {
-    if(opt.sendlist == 0) {
-      fprintf(stderr, "Missing sendlist .\n");
-      usage(argv[0]);
-      exit(1);
-    }
-     
-    one_sendto_many(opt.sendlist);
-  }
-  else if (strcmp("test_net_sendandrecv", opt.fun) == 0) {
-    if(opt.sendlist == 0) {
-      fprintf(stderr, "Missing sendlist .\n");
-      usage(argv[0]);
-      exit(1);
-    }
-     
-    test_net_sendandrecv(opt.sendlist);
-  }
-  else if (strcmp("test_net_pub_threads", opt.fun) == 0) {
-    if(opt.publist == 0) {
-      fprintf(stderr, "Missing publist .\n");
-      usage(argv[0]);
-      exit(1);
-    }
-     
-    test_net_pub_threads(opt.publist);
-  }
-  else if (strcmp("test_net_pub", opt.fun) == 0) {
-    if(opt.publist == 0) {
-      fprintf(stderr, "Missing publist .\n");
-      usage(argv[0]);
-      exit(1);
-    }
-     
-    test_net_pub(opt.publist);
-  }
-  
-  else {
-    usage(argv[0]);
-    exit(1);
-
-  }
-
-  printf("==========end========\n");
-  shm_mm_wrapper_destroy();
-
 }
 
 
@@ -790,3 +703,101 @@
   }
   printf("============node list end==========\n");
 }
+
+
+
+
+int main(int argc, char *argv[]) {
+  shm_mm_wrapper_init(512);
+ 
+  argument_t opt = parse_args(argc, argv);
+
+ // port = atoi(argv[2]);
+   
+  if(opt.fun == NULL) {
+    usage(argv[0]);
+    exit(1);
+  }
+
+  if (strcmp("start_net_proxy", opt.fun) == 0 ) {
+    if(opt.port == 0) {
+      usage(argv[0]);
+      exit(1);
+    }
+    start_net_proxy(opt);
+    
+  }
+  else if (strcmp("start_bus_server", opt.fun) == 0) {
+     
+    start_bus_server(opt);
+  }
+  else if (strcmp("start_reply", opt.fun) == 0) {
+    if(opt.key == 0) {
+      usage(argv[0]);
+      exit(1);
+    }
+    start_reply(opt.key);
+  }
+  else if (strcmp("start_net_client", opt.fun) == 0) {
+    if(opt.sendlist == 0) {
+      fprintf(stderr, "Missing sendlist .\n");
+      usage(argv[0]);
+      exit(1);
+    }
+    if(opt.publist == 0) {
+      fprintf(stderr, "Missing publist.\n");
+      usage(argv[0]);
+      exit(1);
+    }
+    start_net_client(opt.sendlist, opt.publist);
+  }
+  else if (strcmp("one_sendto_many", opt.fun) == 0) {
+    if(opt.sendlist == 0) {
+      fprintf(stderr, "Missing sendlist .\n");
+      usage(argv[0]);
+      exit(1);
+    }
+     
+    one_sendto_many(opt.sendlist);
+  }
+  else if (strcmp("test_net_sendandrecv", opt.fun) == 0) {
+    if(opt.sendlist == 0) {
+      fprintf(stderr, "Missing sendlist .\n");
+      usage(argv[0]);
+      exit(1);
+    }
+     
+    test_net_sendandrecv(opt.sendlist);
+  }
+  else if (strcmp("test_net_pub_threads", opt.fun) == 0) {
+    if(opt.publist == 0) {
+      fprintf(stderr, "Missing publist .\n");
+      usage(argv[0]);
+      exit(1);
+    }
+     
+    test_net_pub_threads(opt.publist);
+  }
+  else if (strcmp("test_net_pub", opt.fun) == 0) {
+    if(opt.publist == 0) {
+      fprintf(stderr, "Missing publist .\n");
+      usage(argv[0]);
+      exit(1);
+    }
+     
+    test_net_pub(opt.publist);
+  }
+  else if (strcmp("start_resycle", opt.fun) == 0) {
+    start_resycle();
+  }
+  
+  else {
+    usage(argv[0]);
+    exit(1);
+
+  }
+
+  printf("==========end========\n");
+  // shm_mm_wrapper_destroy();
+
+}

--
Gitblit v1.8.0