lichao
2021-04-09 2197cf91e7a3bd5941327ba630a42946b88f069e
utest/speed_test.cpp
@@ -40,6 +40,7 @@
      body.set_data(str);
      auto head(InitMsgHead(GetType(body), proc_id));
      msg.MakeRC(shm, head, body);
      assert(msg.IsCounted());
      DEFER1(msg.Release(shm););
      for (uint64_t i = 0; i < n; ++i) {
@@ -127,8 +128,8 @@
   SharedMemory shm(shm_name, 1024 * 1024 * 50);
   auto Avail = [&]() { return shm.get_free_memory(); };
   auto init_avail = Avail();
   ShmMsgQueue srv(shm, qlen);
   ShmMsgQueue cli(shm, qlen);
   ShmSocket srv(shm, qlen);
   ShmSocket cli(shm, qlen);
   MsgI request_rc;
   MsgRequestTopic req_body;
@@ -156,9 +157,9 @@
            req_body.set_topic("topic");
            req_body.set_data(msg_content);
            auto req_head(InitMsgHead(GetType(req_body), client_proc_id));
            return cli.Send(srv.Id(), req_head, req_body, 100);
            return cli.Send(&srv.id(), req_head, req_body, 100);
         };
         auto ReqRC = [&]() { return cli.Send(srv.Id(), request_rc, 1000); };
         auto ReqRC = [&]() { return cli.Send(&srv.id(), request_rc, 1000); };
         if (!ReqRC()) {
            printf("********** client send error.\n");
@@ -166,7 +167,7 @@
         }
         MsgI msg;
         BHMsgHead head;
         if (!cli.Recv(msg, 1000)) {
         if (!cli.SyncRecv(msg, head, 1000)) {
            printf("********** client recv error.\n");
         } else {
            DEFER1(msg.Release(shm));
@@ -187,8 +188,9 @@
      BHMsgHead req_head;
      while (!stop) {
         if (srv.Recv(req, 100)) {
         if (srv.SyncRecv(req, req_head, 100)) {
            DEFER1(req.Release(shm));
            if (req.ParseHead(req_head) && req_head.type() == kMsgTypeRequestTopic) {
               auto &mqid = req_head.route()[0].mq_id();
               MQId src_id;
@@ -198,9 +200,9 @@
                  reply_body.set_topic("topic");
                  reply_body.set_data(msg_content);
                  auto reply_head(InitMsgHead(GetType(reply_body), server_proc_id, req_head.msg_id()));
                  return srv.Send(src_id, reply_head, reply_body, 100);
                  return srv.Send(&src_id, reply_head, reply_body, 100);
               };
               auto ReplyRC = [&]() { return srv.Send(src_id, reply_rc, 100); };
               auto ReplyRC = [&]() { return srv.Send(&src_id, reply_rc, 100); };
               if (ReplyRC()) {
               }