36 lines
No EOL
706 B
C++
Executable file
36 lines
No EOL
706 B
C++
Executable file
|
|
|
|
#ifndef _BoundedBuffer_H_
|
|
#define _BoundedBuffer_H_
|
|
|
|
#include <vector>
|
|
#include <string>
|
|
//#include <semaphore.h>
|
|
|
|
using namespace std;
|
|
|
|
extern unsigned int n, b, w;
|
|
|
|
class BoundedBuffer{
|
|
//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);
|
|
|
|
|
|
|
|
vector<string> data;
|
|
|
|
//BoundedBuffer(
|
|
|
|
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
|
|
};
|
|
|
|
#endif |