| | |
| | | |
| | | |
| | | using namespace std; |
| | | |
| | | int key = 1; |
| | | |
| | | bool stop = false; |
| | | void sigint_handler(int sig) { |
| | | cerr << "sigint_handler" << endl; |
| | | destroy(key); |
| | | exit(0); |
| | | |
| | | printf("sigint_handler\n"); |
| | | stop = true; |
| | | } |
| | | |
| | | int main(int argc, char *argv[]) |
| | |
| | | start = atoi(argv[1]); |
| | | end = atoi(argv[2]); |
| | | } |
| | | //SAbstractQueue<struct Item> *queue = QFactory::createQueue<struct Item> (1, 10); |
| | | 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 */ |
| | |
| | | item.pic = i; |
| | | item.info = i; |
| | | //while((end == -1 || (i < end) ) && (queue->add(item)) ) { |
| | | while((queue->push(item)) ) { |
| | | while(!stop && (queue->push(item)) ) { |
| | | item.pic = i; |
| | | item.info = i; |
| | | |
| | | // cout << "入队:" << item.pic << ", " << item.info << endl; |
| | | cout << item.pic << endl; |
| | | cout << "入队:" << item.pic << ", " << item.info << endl; |
| | | // cout << item.pic << endl; |
| | | |
| | | i++; |
| | | |
| | | } |
| | | destroy(key); |
| | | |
| | | delete queue; |
| | | mm_destroy(); |
| | | cerr << "productor quit" << endl; |
| | | exit(EXIT_SUCCESS); |
| | | } |