V7
This commit is contained in:
parent
9a81d2895f
commit
a89c689ccb
1 changed files with 45 additions and 28 deletions
|
@ -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;
|
string channel_name;
|
||||||
|
if(pid == 0){
|
||||||
for(int i=0; i < w; i++){
|
for(int i=0; i < w; i++){
|
||||||
|
|
||||||
channel_name = chan.send_request("newthread");
|
channel_name = chan.send_request("newthread");
|
||||||
cout << "Chan: " << channel_name << endl;
|
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);
|
Worker_Thread(argv, worker_ret);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
chan.send_request("quit");
|
chan.send_request("quit");
|
||||||
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
usleep(1000000);
|
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){
|
void* Req_Thread(string name){
|
||||||
Request_Buffer->push("data" + name);
|
Request_Buffer->push("data" + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Worker_Thread(char* arg[], RequestChannel* chan){
|
void* local_send_request(){
|
||||||
//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(){
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue