示例#1
0
void BeatBoard::IRCConnection::loggingMessage( string channel, string identifier, string message ){
  stringstream unixtime;
  unixtime << (int)time(NULL);

  BeatBoard::ProtobufQueueMemcached queue;
  logapi::Request request;
  request.set_channel(channel.c_str());
  request.set_time(unixtime.str().c_str());
  request.set_identifier(identifier.c_str());
  request.set_message(message.c_str());
  std::string data;
  if ( !request.SerializeToString( &data ) ){
    std::cout << "Failed to parse request." << std::endl;
    //error...
    //return false;
  }
  
  int count = 3;
  for (int i = 0; i < count; i++){
    if (queue.enqueue(data) != -1)
      {
        break;
      }
  }
}
示例#2
0
int iteration(int count){
  BeatBoard::ProtobufQueueMemcached queue;

  for(int i = 0; i < count; i++){
    queue.enqueue(string("koko ni protobuf no data ireruyo-"));
  }
    
  string *value;
  while((value = queue.dequeue_nb()) != NULL){
    cout << *value << endl;
    delete value;
  }
  return 0;
}