-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
51 lines (44 loc) · 906 Bytes
/
main.cpp
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
Author: AlexString
Description:
This file demonstrates the use of
ConsumerProducer_Class
*/
#include <iostream>
#include <limits>
#include "ConsumerProducer.h"
using namespace std;
int menu(){
int desition;
cout << "--Menu--" << endl;
cout << "1) Producer"
"\n2) Consumer"
"\n3) Exit." << endl;
cin >> desition;
return desition;
}
int main(){
ConsumerProducer_Class consumer_producer;
cout << "Producer / Consumer demonstration using Semaphores" << endl;
while(1){
int select = menu();
switch(select){
case 1:{
cin.ignore(numeric_limits<streamsize>::max(),'\n');
string item;
cout << "Insert item:" << endl;
getline(cin, item);
std::cout << "Sending [ "<< item << " ] to producer." << std::endl;
consumer_producer.useProducer(item);
}
break;
case 2:
consumer_producer.useConsumer();
break;
default:
exit(0);
break;
}
}
return 0;
}