lichao
2021-04-20 ca319178f45ce6256aed7913565d445571f6db22
utest/utest.cpp
@@ -198,7 +198,7 @@
{
   const std::string shm_name("ShmReqRep");
   ShmRemover auto_remove(shm_name);
   SharedMemory shm(shm_name, 1024 * 1024 * 50);
   SharedMemory shm(shm_name, 1024 * 1024 * 512);
   auto Avail = [&]() { return shm.get_free_memory(); };
   auto init_avail = Avail();
@@ -224,22 +224,24 @@
            printf("count: %d\n", count.load());
         }
      };
      MsgRequestTopic req;
      req.set_topic(topic);
      req.set_data("data " + std::string(100, 'a'));
      client.ClientStartWorker(onRecv, 2);
      boost::timer::auto_cpu_timer timer;
      for (int i = 0; i < nreq; ++i) {
         MsgRequestTopic req;
         req.set_topic(topic);
         req.set_data("data " + std::to_string(i));
         std::string msg_id;
         if (!client.ClientAsyncRequest(req, msg_id)) {
            printf("client request failed\n");
            ++count;
         }
         // if (!client.SyncRequest(topic, "data " + std::to_string(i), reply, 1000)) {
         // std::string proc_id;
         // MsgRequestTopicReply reply;
         // if (!client.ClientSyncRequest(req, proc_id, reply, 1000)) {
         //    printf("client request failed\n");
         // }
         //    ++count;
         // ++count;
      }
      do {
         std::this_thread::yield();
@@ -278,7 +280,7 @@
   servers.Launch(Server, "server", topics);
   Sleep(100ms);
   for (auto &t : topics) {
      clients.Launch(Client, t, 1000 * 100);
      clients.Launch(Client, t, 1000 * 100 * 2);
   }
   clients.WaitAll();
   printf("clients done, server replyed: %ld\n", server_msg_count.load());