| | |
| | | ShmRemover auto_remove(shm_name); |
| | | const int mem_size = 1024 * 1024 * 50; |
| | | MQId id = boost::uuids::random_generator()(); |
| | | const int timeout = 100; |
| | | const int timeout = 1000; |
| | | const uint32_t data_size = 4000; |
| | | const std::string proc_id = "demo_proc"; |
| | | |
| | |
| | | DEFER1(msg.Release(shm);); |
| | | |
| | | for (uint64_t i = 0; i < n; ++i) { |
| | | // mq.Send(id, str.data(), str.size(), timeout); |
| | | mq.Send(id, msg, timeout); |
| | | } |
| | | }; |
| | |
| | | www.Launch(Writer, i, nmsg); |
| | | } |
| | | www.WaitAll(); |
| | | printf("writer finished\n"); |
| | | run.store(false); |
| | | rrr.WaitAll(); |
| | | printf("Write %ld msg R(%3d) W(%3d), : ", total_msg, nreader, nwriter); |
| | |
| | | req_body.set_topic("topic"); |
| | | req_body.set_data(msg_content); |
| | | auto req_head(InitMsgHead(GetType(req_body), client_proc_id)); |
| | | req_head.add_route()->set_mq_id(&cli.id(), cli.id().size()); |
| | | request_rc.MakeRC(shm, req_head, req_body); |
| | | DEFER1(request_rc.Release(shm)); |
| | | |
| | | MsgRequestTopic reply_body; |
| | | reply_body.set_topic("topic"); |
| | | reply_body.set_data(msg_content); |
| | | auto reply_head(InitMsgHead(GetType(reply_body), server_proc_id)); |
| | | reply_head.add_route()->set_mq_id(&srv.id(), srv.id().size()); |
| | | MsgI reply_rc; |
| | | reply_rc.MakeRC(shm, reply_head, reply_body); |
| | | DEFER1(reply_rc.Release(shm)); |
| | | |
| | | std::atomic<uint64_t> count(0); |
| | | |
| | |
| | | printf("request ok: %ld\n", count.load()); |
| | | stop = true; |
| | | servers.WaitAll(); |
| | | BOOST_CHECK(request_rc.IsCounted()); |
| | | BOOST_CHECK_EQUAL(request_rc.Count(), 1); |
| | | request_rc.Release(shm); |
| | | BOOST_CHECK(!request_rc.IsCounted()); |
| | | // BOOST_CHECK_THROW(reply.Count(), int); |
| | | } |