This repository has been archived on 2025-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
csce313-mp4pinie64backup/BoundedBuffer.h

31 lines
615 B
C
Raw Normal View History

2015-11-06 11:01:19 -06:00
2015-11-06 11:56:25 -06:00
#include <vector>
using namespace std;
unsigned int n = 20, b = 100, w = 5;
2015-11-06 11:01:19 -06:00
2015-11-06 11:30:46 -06:00
class BoundedBuffer{
2015-11-06 11:56:25 -06:00
//int b;
Semaphore *full = new Semaphore(0); //initialized to 0, Since there are 0 full slots
Semaphore *empty = new Semaphore(b); //initialized to b, Since all the slots are empty
Semaphore *mutex = new Semaphore(1);
2015-11-06 11:30:46 -06:00
vector<string> data;
2015-11-06 11:56:25 -06:00
//BoundedBuffer(
2015-11-06 11:30:46 -06:00
void set_b(int val_b){ b = val_b;}
void push(string item);
void pop();
//can't be larger than b strings
//b = user input
2015-11-06 11:56:25 -06:00
};
2015-11-06 11:01:19 -06:00