From 7d3086a481899b03c230eb06a29aa57677041725 Mon Sep 17 00:00:00 2001
From: wangzhengquan <wangzhengquan85@126.com>
Date: 星期三, 08 七月 2020 15:07:51 +0800
Subject: [PATCH] update

---
 test/multiple_queue_productor.c |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/test/multiple_queue_productor.c b/test/multiple_queue_productor.c
index 9e7c0e9..f01652e 100644
--- a/test/multiple_queue_productor.c
+++ b/test/multiple_queue_productor.c
@@ -6,12 +6,10 @@
 #define NTHREADS 4 
 struct Targ targs[NTHREADS];
 size_t qsize = 16;
-
+bool stop = false;
 void sigint_handler(int sig) {
   cerr << "sigint_handler" << endl;
-  mm_destroy();
-  exit(0);
-
+  stop = true;
 }
 
 void* run (void *arg) {
@@ -19,10 +17,9 @@
   struct Targ * targ = (struct Targ * )arg;
  // cerr << "productor key="<<targ->key << endl;
   err_msg(0, "productor key = %d\n", targ->key );
-  //SLinkedLockFreeQueue<struct Item> *queue = QFactory::createLinkedLockFreeQueue<struct Item> (targ->key, 10);
-  //SArrayLockFreeQueue<struct Item> *queue = QFactory::createArrayLockFreeQueue<struct Item> (targ->key, 10);
   
-  LockFreeQueue<struct Item> *queue = QueueFactory::createQueue<struct Item> (targ->key, qsize);
+ // LockFreeQueue<struct Item> *queue = QueueFactory::createQueue<struct Item> (targ->key, qsize);
+ SHMQueue<struct Item> *queue = new SHMQueue<struct Item>(targ->key, qsize);
   /* Transfer blocks of data from stdin to shared memory */
   int end = targ->end;
   struct Item item;
@@ -32,7 +29,7 @@
 
   item.pic = i;
   item.info = i;
-  while((end == -1 || (i < end) ) && (queue->push(item)) ) {
+  while(!stop && (end == -1 || (i < end) ) && (queue->push(item)) ) {
     item.pic = i;
     item.info = i;
     printf("productor(%d) 鍏ラ槦锛歿%d, %d}\n", targ->key, item.pic,  item.info);
@@ -40,6 +37,7 @@
     i++;
     
   }
+  delete queue;
   return (void *)i;
 }
 
@@ -77,7 +75,7 @@
   }
 
   
-  //destroy();
+  mm_destroy();
   cerr << "productor quit" << endl;
   exit(EXIT_SUCCESS);
 }

--
Gitblit v1.8.0