From ad4f3dcedab29a690c5eedbb08ba1b393917db0b Mon Sep 17 00:00:00 2001 From: lichao <lichao@aiotlink.com> Date: 星期三, 21 四月 2021 17:39:34 +0800 Subject: [PATCH] update go api. --- utest/util.h | 33 +++++++++++++++++++++++++++++---- 1 files changed, 29 insertions(+), 4 deletions(-) diff --git a/utest/util.h b/utest/util.h index ca58cd7..4d960db 100644 --- a/utest/util.h +++ b/utest/util.h @@ -20,9 +20,7 @@ #define UTIL_W8A0OA5U #include "bh_util.h" -#include "msg.h" -#include "shm.h" -#include "shm_queue.h" +#include "topic_node.h" #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/noncopyable.hpp> #include <boost/test/unit_test.hpp> @@ -36,9 +34,17 @@ #include <vector> using namespace boost::posix_time; -inline ptime Now() { return second_clock::universal_time(); }; using namespace std::chrono_literals; + +template <class D> +inline void Sleep(D d, bool print = true) +{ + if (print) { + printf("sleep for %ld ms\n", std::chrono::duration_cast<std::chrono::milliseconds>(d).count()); + } + std::this_thread::sleep_for(d); +} typedef std::function<void(void)> FuncVV; @@ -107,4 +113,23 @@ ~ShmRemover() { SharedMemory::Remove(name_); } }; +class DemoNode : public TopicNode +{ + std::string id_; + +public: + DemoNode(const std::string &id, SharedMemory &shm) : + TopicNode(shm), id_(id) { Init(); } + void Init() + { + ProcInfo proc; + proc.set_proc_id(id_); + MsgCommonReply reply_body; + + if (!Register(proc, reply_body, 1000)) { + printf("node %s register failed\n", id_.c_str()); + } + } +}; + #endif // end of include guard: UTIL_W8A0OA5U -- Gitblit v1.8.0