#include "test.h" using namespace std; void sigint_handler(int sig) { cerr << "sigint_handler" << endl; destroy(); exit(0); } int main(int argc, char *argv[]) { void *shmp; string line; signal(SIGINT, sigint_handler); /* Create set containing two semaphores; initialize so that writer has first access to shared memory. */ int start = 0; int end = -1; if (argc == 3) { start = atoi(argv[1]); end = atoi(argv[2]); } //SAbstractQueue *queue = QFactory::createQueue (1, 10); SLinkedLockFreeQueue *queue = QFactory::createLinkedLockFreeQueue (1, 10); /* Transfer blocks of data from stdin to shared memory */ struct Item item; struct timespec timeout = {5, 0}; int i = start; item.pic = i; item.info = i; //while((end == -1 || (i < end) ) && (queue->add(item)) ) { while((queue->add(item)) ) { item.pic = i; item.info = i; // cout << "入队:" << item.pic << ", " << item.info << endl; cout << item.pic << endl; i++; } destroy(); cerr << "productor quit" << endl; exit(EXIT_SUCCESS); }