From 37a7bd95042c19d7334b099d50ac6dc8e07e4b4e Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期二, 07 七月 2020 16:40:51 +0800 Subject: [PATCH] update --- test/single_consumer.c | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-) diff --git a/test/single_consumer.c b/test/single_consumer.c index a834d86..bfd45c1 100644 --- a/test/single_consumer.c +++ b/test/single_consumer.c @@ -2,33 +2,34 @@ using namespace std; - +int key = 1; void sigint_handler(int sig) { - destroy(); + destroy(key); exit(0); } int main(int argc, char *argv[]) { - - void *shmp; + int qsize = 16; + signal(SIGINT, sigint_handler); /* Get IDs for semaphore set and shared memory created by writer */ //SAbstractQueue<struct Item> *queue = QFactory::createQueue<struct Item> (1, 10); - SLinkedLockFreeQueue<struct Item> *queue = QFactory::createLinkedLockFreeQueue<struct Item> (1, 10); + + LockFreeQueue<struct Item> *queue = QueueFactory::createQueue<struct Item> (key, qsize); /* Transfer blocks of data from shared memory to stdout */ struct timespec timeout = {10, 0}; struct Item item; - while(queue->remove(item)) { + while(queue->pop(item)) { cout << item.pic << endl; //sleep(1); } - destroy(); + destroy(key); cerr << "consumer quit" << endl; exit(EXIT_SUCCESS); } -- Gitblit v1.8.0