当前位置: 首页>>代码示例>>C++>>正文


C++ RequestChannel类代码示例

本文整理汇总了C++中RequestChannel的典型用法代码示例。如果您正苦于以下问题:C++ RequestChannel类的具体用法?C++ RequestChannel怎么用?C++ RequestChannel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RequestChannel类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: worker_thread

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);
	}
}
开发者ID:hoppertim,项目名称:CSCE_313_MP5,代码行数:14,代码来源:client.C

示例2: process_newthread

void process_newthread(RequestChannel & _channel, const string & _request) {
  int error;
  nthreads ++;

  // -- Name new data channel

  string new_channel_name = "data" + int2string(nthreads) + "_";
  //  cout << "new channel name = " << new_channel_name << endl;

  // -- Pass new channel name back to client

  _channel.cwrite(new_channel_name);

  // -- Construct new data channel (pointer to be passed to thread function)
  
  RequestChannel * data_channel = new RequestChannel(new_channel_name, RequestChannel::SERVER_SIDE);

  // -- Create new thread to handle request channel

  pthread_t thread_id;
  //  cout << "starting new thread " << nthreads << endl;
  if (error = pthread_create(& thread_id, NULL, handle_data_requests, data_channel)) {
    fprintf(stderr, "p_create failed: %s\n", strerror(error));
  }  

}
开发者ID:Coltosaur,项目名称:Programming-Portfolio,代码行数:26,代码来源:dataserver.C

示例3: handle_process_loop

void handle_process_loop(RequestChannel & _channel) {

  for(;;) {

    cout << "Reading next request from channel (" << _channel.name() << ") ..." << flush;
    string request = _channel.cread();
    cout << " done (" << _channel.name() << ")." << endl;
    cout << "New request is " << request << endl;

    if (request.compare("quit") == 0) {
      _channel.cwrite("bye");
      usleep(10000);          // give the other end a bit of time.
      break;                  // break out of the loop;
    }

    process_request(_channel, request);
  }
  
}
开发者ID:Coltosaur,项目名称:Programming-Portfolio,代码行数:19,代码来源:dataserver.C

示例4: worker_thread

// 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;
}
开发者ID:rywal,项目名称:CSCE313-MP4,代码行数:21,代码来源:simpleclient.cpp

示例5: process_request

void process_request(RequestChannel & _channel, const string & _request) {

  if (_request.compare(0, 5, "hello") == 0) {
    process_hello(_channel, _request);
  }
  else if (_request.compare(0, 4, "data") == 0) {
    process_data(_channel, _request);
  }
  else if (_request.compare(0, 9, "newthread") == 0) {
    process_newthread(_channel, _request);
  }
  else {
    _channel.cwrite("unknown request");
  }

}
开发者ID:Coltosaur,项目名称:Programming-Portfolio,代码行数:16,代码来源:dataserver.C

示例6: process_data

void process_data(RequestChannel & _channel, const string &  _request) {
  usleep(1000 + (rand() % 5000));
  //_channel.cwrite("here comes data about " + _request.substr(4) + ": " + int2string(random() % 100));
  _channel.cwrite(int2string(rand() % 100));
}
开发者ID:Coltosaur,项目名称:Programming-Portfolio,代码行数:5,代码来源:dataserver.C

示例7: process_hello

void process_hello(RequestChannel & _channel, const string & _request) {
  _channel.cwrite("hello to you too");
}
开发者ID:Coltosaur,项目名称:Programming-Portfolio,代码行数:3,代码来源:dataserver.C


注:本文中的RequestChannel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。