Major OverHaul
This commit is contained in:
commit
1d5ff9403d
4 changed files with 66 additions and 0 deletions
0
BoundedBuffer.cpp
Executable file → Normal file
0
BoundedBuffer.cpp
Executable file → Normal file
0
BoundedBuffer.h
Executable file → Normal file
0
BoundedBuffer.h
Executable file → Normal file
|
@ -158,6 +158,7 @@ void handle_process_loop(RequestChannel & _channel) {
|
||||||
cout << "New request is " << request << endl;
|
cout << "New request is " << request << endl;
|
||||||
|
|
||||||
if (request.compare("quit") == 0) {
|
if (request.compare("quit") == 0) {
|
||||||
|
cout << "\nquit\n";
|
||||||
_channel.cwrite("bye");
|
_channel.cwrite("bye");
|
||||||
usleep(10000); // give the other end a bit of time.
|
usleep(10000); // give the other end a bit of time.
|
||||||
break; // break out of the loop;
|
break; // break out of the loop;
|
||||||
|
|
|
@ -99,11 +99,52 @@ int main(int argc, char * argv[]) {
|
||||||
|
|
||||||
|
|
||||||
RequestChannel chan("control", RequestChannel::CLIENT_SIDE);
|
RequestChannel chan("control", RequestChannel::CLIENT_SIDE);
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
pthread_t request_thread_ids[3];
|
pthread_t request_thread_ids[3];
|
||||||
pthread_t worker_thread_ids[w];
|
pthread_t worker_thread_ids[w];
|
||||||
pthread_t statistic_thread_ids[3];
|
pthread_t statistic_thread_ids[3];
|
||||||
RequestChannel* worker_return[w];
|
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");
|
chan.send_request("quit");
|
||||||
}else{
|
}else{
|
||||||
|
<<<<<<< HEAD
|
||||||
execl("dataserver", 0);
|
execl("dataserver", 0);
|
||||||
|
=======
|
||||||
|
execve("dataserver", argv, argv);
|
||||||
|
>>>>>>> 7f3859db688a7e8629c7a88e7baad87ad6df405d
|
||||||
|
>>>>>>> 4a988cc17197484a727d1eafa31fc5dc8788b952
|
||||||
}
|
}
|
||||||
usleep(1000000);
|
usleep(1000000);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
void* Worker_Thread(void* arg){
|
void* Worker_Thread(void* arg){
|
||||||
RequestChannel* chann = (RequestChannel*)arg;
|
RequestChannel* chann = (RequestChannel*)arg;
|
||||||
while(true){
|
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
|
}else if(request == "quit"){ //Break out of the thread if quit response is found
|
||||||
break;
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue