| | |
| | | |
| | | using namespace std; |
| | | |
| | | int key = 1; |
| | | |
| | | void sigint_handler(int sig) { |
| | | cerr << "sigint_handler" << endl; |
| | | destroy(); |
| | | destroy(key); |
| | | exit(0); |
| | | |
| | | } |
| | | |
| | | int main(int argc, char *argv[]) |
| | | { |
| | | void *shmp; |
| | | string line; |
| | | signal(SIGINT, sigint_handler); |
| | | int qsize = 16; |
| | | |
| | | /* Create set containing two semaphores; initialize so that |
| | | writer has first access to shared memory. */ |
| | | int start = 0; |
| | |
| | | end = atoi(argv[2]); |
| | | } |
| | | //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 stdin to shared memory */ |
| | |
| | | item.pic = i; |
| | | item.info = i; |
| | | //while((end == -1 || (i < end) ) && (queue->add(item)) ) { |
| | | while((queue->add(item)) ) { |
| | | while((queue->push(item)) ) { |
| | | item.pic = i; |
| | | item.info = i; |
| | | |
| | |
| | | i++; |
| | | |
| | | } |
| | | destroy(); |
| | | destroy(key); |
| | | cerr << "productor quit" << endl; |
| | | exit(EXIT_SUCCESS); |
| | | } |