#include "test.h"
|
using namespace std;
|
|
SQueue<struct Item> *queue;
|
|
|
void sigint_handler(int sig) {
|
destroy();
|
exit(0);
|
|
}
|
int main(int argc, char *argv[])
|
{
|
|
|
void *shmp;
|
signal(SIGINT, sigint_handler);
|
/* Get IDs for semaphore set and shared memory created by writer */
|
|
int first = mm_init(sizeof(SQueue<struct Item>), &shmp);
|
|
if (first == 1)
|
queue = new(shmp) SQueue<struct Item>;
|
else
|
queue = (SQueue<struct Item> *) shmp;
|
/* Transfer blocks of data from shared memory to stdout */
|
|
struct timespec timeout = {5, 0};
|
struct Item item;
|
while(queue->dequeue_timeout(item, &timeout)) {
|
|
cout << item.pic << endl;
|
//sleep(1);
|
}
|
|
|
cerr << "consumer quit" << endl;
|
exit(EXIT_SUCCESS);
|
}
|