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[]) {
|
|||
}
|
||||
}
|
||||
|
||||
string channel_name;
|
||||
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_Thread(argv, worker_ret);
|
||||
// 0 is the parent.
|
||||
|
||||
|
||||
for(int i=0; i < 3; i++){
|
||||
//stat thread
|
||||
|
||||
pid = fork();
|
||||
if(pid != 0){
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
chan.send_request("quit");
|
||||
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;
|
||||
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);
|
||||
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(){
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue