Ejemplo n.º 1
0
// Function to be performed by worker thread
void* worker_thread(void* channel_id) {
    RequestChannel *channel = (RequestChannel *) channel_id;
    Response response("something", 0, 0);
    
    // Keep sending responses from buffer until told to 'quit'
    while(true){
        // Pull next response from buffer
        response = buffer->pop();
        //cout << "Response: " << response.data << "\n";
        // Quit if told to
        if(response.data == "quit") break;
    
        // Send request, and save response to appropriate buffer
        string reply = channel->send_request(response.data);
        response.data = reply;
        response_buffers[response.req_id]->push(response);
    }
    channel->send_request("quit");
    return 0;
}
Ejemplo n.º 2
0
void* worker_thread(void* args){
	RequestChannel* channel = (RequestChannel*)args;	//cast input to a RequestChannel
	while (true){
		string request = buffer->remove();	//get the request from the buffer
		string reply = channel->send_request(request);	//send the request through the channel to the dataserver
		string name = request.substr(5);
		int person_num = 0;
		if (name == "Jane Smith")
			person_num = 1;
		else if (name == "John Doe")
			person_num = 2;
		stat_buffer[person_num]->add(reply);
	}
}