From 1b52f1cb8c47dd2c0195d2fd65d7b6a4c2f10704 Mon Sep 17 00:00:00 2001 From: lichao <lichao@aiotlink.com> Date: 星期一, 12 四月 2021 18:29:41 +0800 Subject: [PATCH] add fail-resend support. --- utest/utest.cpp | 26 +++++++++++++++++++++++++- 1 files changed, 25 insertions(+), 1 deletions(-) diff --git a/utest/utest.cpp b/utest/utest.cpp index a178fab..e0a9023 100644 --- a/utest/utest.cpp +++ b/utest/utest.cpp @@ -1,5 +1,6 @@ #include "center.h" #include "defs.h" +#include "failed_msg.h" #include "util.h" #include <atomic> #include <boost/uuid/uuid_generators.hpp> @@ -21,8 +22,28 @@ static const bool value = true; }; +typedef FailedMsgQ ServerFailedQ; + BOOST_AUTO_TEST_CASE(Temp) { + const std::string shm_name("ShmTemp"); + ShmRemover auto_remove(shm_name); //remove twice? in case of killed? + SharedMemory shm(shm_name, 1024 * 1024 * 10); + + typedef std::chrono::steady_clock clock; + int n = 1000 * 1000; + std::vector<clock::time_point> tps(n); + { + printf("thread switch %d times, ", n); + boost::timer::auto_cpu_timer timer; + for (auto &tp : tps) { + tp = clock::now(); + std::this_thread::yield(); + } + } + printf("time: %ld ns\n", (tps.back() - tps.front()).count()); + return; + // sub topic partial match. Topic topics[] = { "", ".", @@ -131,7 +152,9 @@ bool r = provider.Publish(topic, data.data(), data.size(), timeout); if (!r) { - printf("pub ret: %s\n", r ? "ok" : "fail"); + static std::atomic<int> an(0); + int n = ++an; + printf("pub %d ret: %s\n", n, r ? "ok" : "fail"); } } }; @@ -142,6 +165,7 @@ topics.push_back("t" + std::to_string(i)); } Topics part; + boost::timer::auto_cpu_timer pubsub_timer; for (size_t i = 0; i < topics.size(); ++i) { part.push_back(topics[i]); threads.Launch(Sub, i, topics); -- Gitblit v1.8.0