From af86015d724e5edf001aa024fe7d8581c45cffd9 Mon Sep 17 00:00:00 2001 From: lichao <lichao@aiotlink.com> Date: 星期四, 15 四月 2021 10:44:12 +0800 Subject: [PATCH] fix sendq lock, use different mutexes for in,out. --- src/proto.h | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/src/proto.h b/src/proto.h index 2057711..42fe343 100644 --- a/src/proto.h +++ b/src/proto.h @@ -19,6 +19,8 @@ #define PROTO_UA9UWKL1 #include "bhome_msg.pb.h" +#include "bhome_msg_api.pb.h" +#include <chrono> using namespace bhome::msg; @@ -74,5 +76,16 @@ BHMsgHead InitMsgHead(const MsgType type, const std::string &proc_id, const std::string &msgid); BHMsgHead InitMsgHead(const MsgType type, const std::string &proc_id); // inline void AddRoute(BHMsgHead &head, const MQId &id) { head.add_route()->set_mq_id(&id, sizeof(id)); } +inline bool IsSuccess(const ErrorCode ec) { return ec == eSuccess; } +bool IsMsgExpired(const BHMsgHead &head); + +inline int64_t CountSeconds(const std::chrono::steady_clock::time_point tp) +{ + return std::chrono::duration_cast<std::chrono::seconds>(tp.time_since_epoch()).count(); +} +inline int64_t NowSec() +{ + return CountSeconds(std::chrono::steady_clock::now()); +} #endif // end of include guard: PROTO_UA9UWKL1 -- Gitblit v1.8.0