wangzhengquan
2020-07-07 37a7bd95042c19d7334b099d50ac6dc8e07e4b4e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "test.h"
using namespace std;
 
 
int key = 1;
 
void sigint_handler(int sig) {
  destroy(key);
  exit(0);
 
}
int main(int argc, char *argv[])
{
   
  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);
 
  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->pop(item)) {
    
    cout <<  item.pic  << endl;
    //sleep(1);
  }
 
  destroy(key);
  cerr << "consumer quit" << endl;
  exit(EXIT_SUCCESS);
}