This commit is contained in:
Eric Buxkemper 2015-11-09 18:16:10 -06:00
parent 9a81d2895f
commit a89c689ccb

View file

@ -107,40 +107,57 @@ int main(int argc, char * argv[]) {
}
}
// 0 is the parent.
for(int i=0; i < 3; i++){
//stat thread
pid = fork();
if(pid != 0){
break;
}
}
RequestChannel* worker_ret;
string channel_name;
if(pid == 0){
for(int i=0; i < w; i++){
channel_name = chan.send_request("newthread");
cout << "Chan: " << channel_name << endl;
RequestChannel* worker_ret = new RequestChannel(channel_name, RequestChannel::CLIENT_SIDE);
worker_ret = new RequestChannel(channel_name, RequestChannel::CLIENT_SIDE);
pid = fork();
if(pid != 0) {
Worker_Thread(argv, worker_ret);
break;
}
}
chan.send_request("quit");
} else {
}
}
usleep(1000000);
}
void* Worker_Thread(char* arg[], RequestChannel* chan){
while(true){
string req = Request_Buffer->pop();
cout << "Request: " << req << endl;
string response = chan->send_request(req);
cout << "Response: " << response << endl;
}
chan->send_request("quit");
}
void* Req_Thread(string name){
Request_Buffer->push("data" + name);
}
void* Worker_Thread(char* arg[], RequestChannel* chan){
//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){
string req = Request_Buffer->pop();
cout << "Request: " << req << endl;
string response = chan->send_request(req);
cout << "Response: " << response << endl;
}
chan->send_request("quit");
}
string local_send_request(){
void* local_send_request(){
}