Major OverHaul

This commit is contained in:
Eric Buxkemper 2015-11-11 15:34:16 -06:00
commit 1d5ff9403d
4 changed files with 66 additions and 0 deletions

0
BoundedBuffer.cpp Executable file → Normal file
View file

0
BoundedBuffer.h Executable file → Normal file
View file

View file

@ -158,6 +158,7 @@ void handle_process_loop(RequestChannel & _channel) {
cout << "New request is " << request << endl;
if (request.compare("quit") == 0) {
cout << "\nquit\n";
_channel.cwrite("bye");
usleep(10000); // give the other end a bit of time.
break; // break out of the loop;

View file

@ -99,11 +99,52 @@ int main(int argc, char * argv[]) {
RequestChannel chan("control", RequestChannel::CLIENT_SIDE);
<<<<<<< HEAD
pthread_t request_thread_ids[3];
pthread_t worker_thread_ids[w];
pthread_t statistic_thread_ids[3];
RequestChannel* worker_return[w];
=======
cout << "done." << endl;
for(int i = 0; i < 3; i++){
pid = fork();
if(pid){ //if in the parent still
if(i == 0){
Req_Thread(" Joe Smith");
}else if(i == 1){
Req_Thread(" Jane Smith");
}else if(i == 2){
Req_Thread(" John Doe");
}
continue;
}else if (pid == 0){
break;
} else {
exit(1);
}
}
<<<<<<< HEAD
string channel_name;
for(int i=0; i < w; i++){
channel_name = chan.send_request("newthread");
cout << "\nChan: " << channel_name << endl;
RequestChannel* worker_ret = new RequestChannel(channel_name, RequestChannel::CLIENT_SIDE);
pid = fork();
if(pid != 0) {
Worker_Thread(argv, worker_ret);
break;
}
}
chan.send_request("quit");
=======
>>>>>>> 4a988cc17197484a727d1eafa31fc5dc8788b952
@ -157,12 +198,18 @@ int main(int argc, char * argv[]) {
chan.send_request("quit");
}else{
<<<<<<< HEAD
execl("dataserver", 0);
=======
execve("dataserver", argv, argv);
>>>>>>> 7f3859db688a7e8629c7a88e7baad87ad6df405d
>>>>>>> 4a988cc17197484a727d1eafa31fc5dc8788b952
}
usleep(1000000);
}
<<<<<<< HEAD
void* Worker_Thread(void* arg){
RequestChannel* chann = (RequestChannel*)arg;
while(true){
@ -177,6 +224,24 @@ void* Worker_Thread(void* arg){
}else if(request == "quit"){ //Break out of the thread if quit response is found
break;
}
=======
void* Worker_Thread(char* arg[], RequestChannel* chan){
<<<<<<< HEAD
//handles the data moving between the Server and Bounded Buffer
//control chan("control", RequestChannel::CLIENT_SIDE);
//string channel_name = control.send_request("newthread");
//RequestChannel * channel_ret = new RequestChannel(channel_name, RequestChannel::CLIENT_SIDE);
while(true){
=======
while(true){
>>>>>>> 7f3859db688a7e8629c7a88e7baad87ad6df405d
string req = Request_Buffer->pop();
cout << "Request: " << req << endl;
string response = chan->send_request(req);
cout << "Response: " << response << endl;
//local_send_request(req, response);
>>>>>>> 4a988cc17197484a727d1eafa31fc5dc8788b952
}
}