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/test_timeout.c | 24 ++++++++++-------------- 1 files changed, 10 insertions(+), 14 deletions(-) diff --git a/test/test_timeout.c b/test/test_timeout.c index 86dcff8..3fe071d 100644 --- a/test/test_timeout.c +++ b/test/test_timeout.c @@ -4,17 +4,10 @@ using namespace std; int key = 2; size_t qsize = 16; - -// 閿�姣佸叡浜唴瀛樺拰淇″彿 -void sigint_handler(int sig) { - destroy(key); - exit(0); - -} - + void productor() { - LockFreeQueue<struct Item> *queue = QueueFactory::createQueue<struct Item> (key, qsize); - + // LockFreeQueue<struct Item> *queue = QueueFactory::createQueue<struct Item> (key, qsize); + SHMQueue<struct Item> *queue = new SHMQueue<struct Item>(key, qsize); /* Transfer blocks of data from stdin to shared memory */ struct Item item; struct timespec timeout = {5, 0}; @@ -43,11 +36,12 @@ i++; } + delete queue; } void consumer() { - LockFreeQueue<struct Item> *queue = QueueFactory::createQueue<struct Item> (key, qsize); + SHMQueue<struct Item> *queue = new SHMQueue<struct Item>(key, qsize); /* Transfer blocks of data from shared memory to stdout */ while(1) { @@ -68,17 +62,19 @@ } } + delete queue; } + int main(int argc, char *argv[]) { - signal(SIGINT, sigint_handler); + productor(); consumer(); - // 閿�姣佸叡浜唴瀛樺拰淇″彿 - destroy(key); + // 閿�姣佸叡浜唴瀛� + mm_destroy(); exit(EXIT_SUCCESS); } -- Gitblit v1.8.0