diff --git a/BoundedBuffer.cpp b/BoundedBuffer.cpp index a64a667..292a9e4 100755 --- a/BoundedBuffer.cpp +++ b/BoundedBuffer.cpp @@ -1,10 +1,17 @@ +#include "semaphore.h" +#include "BoundedBuffer.h" +//#include "semaphore.h" +//#include +#include +#include + void BoundedBuffer::push(string item){ - empty.P(); + empty->P(); data.push_back(item); - full.V();//increment the number of full slots now. + full->V();//increment the number of full slots now. } void BoundedBuffer::pop(){ diff --git a/BoundedBuffer.h b/BoundedBuffer.h index 5d14b02..2420fdd 100755 --- a/BoundedBuffer.h +++ b/BoundedBuffer.h @@ -1,9 +1,15 @@ + +#ifndef _BoundedBuffer_H_ +#define _BoundedBuffer_H_ + #include +#include +//#include using namespace std; -unsigned int n = 20, b = 100, w = 5; +extern unsigned int n, b, w; class BoundedBuffer{ @@ -20,9 +26,9 @@ class BoundedBuffer{ void push(string item); void pop(); - //can't be larger than b strings //b = user input }; +#endif diff --git a/makefile b/makefile index 13e1369..106521b 100755 --- a/makefile +++ b/makefile @@ -8,5 +8,9 @@ reqchannel.o: reqchannel.h reqchannel.cpp dataserver: dataserver.cpp reqchannel.o g++ -std=c++11 -g -o dataserver dataserver.cpp reqchannel.o -lpthread -simpleclient: simpleclient.cpp reqchannel.o - g++ -std=c++11 -g -o simpleclient simpleclient.cpp reqchannel.o +simpleclient: simpleclient.cpp reqchannel.o BoundedBuffer.cpp + g++ -std=c++11 -g -o simpleclient simpleclient.cpp reqchannel.o BoundedBuffer.cpp + +clean: + $(RM) *.o + diff --git a/simpleclient.cpp b/simpleclient.cpp index 428afdd..b7b9863 100755 --- a/simpleclient.cpp +++ b/simpleclient.cpp @@ -44,8 +44,6 @@ using namespace std; /* CONSTANTS */ /*--------------------------------------------------------------------------*/ -// unsigned int n = 20, b = 100, w = 5; - /* -- (none) -- */ /*--------------------------------------------------------------------------*/ @@ -62,6 +60,9 @@ int main(int argc, char * argv[]) { int option = -1; + unsigned int n; + unsigned int b; + unsigned int w; while ((option = getopt(argc, argv, "n:b:w:")) != -1){ switch (option){ case 'n' :