From 34cd75f77d0ca94dbdba4e6cc9451fe4d33e78b3 Mon Sep 17 00:00:00 2001
From: lichao <lichao@aiotlink.com>
Date: 星期三, 19 五月 2021 19:14:13 +0800
Subject: [PATCH] add api BHQueryProcs.

---
 src/shm_msg_queue.h |   23 ++++++++---------------
 1 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/src/shm_msg_queue.h b/src/shm_msg_queue.h
index 4b7aed8..de60fde 100644
--- a/src/shm_msg_queue.h
+++ b/src/shm_msg_queue.h
@@ -18,6 +18,7 @@
 #ifndef SHM_MSG_QUEUE_D847TQXH
 #define SHM_MSG_QUEUE_D847TQXH
 
+#include "defs.h"
 #include "msg.h"
 #include "shm_queue.h"
 
@@ -47,13 +48,14 @@
 
 	static MQId NewId();
 
-	ShmMsgQueue(const MQId id, ShmType &segment, const int len);
-	ShmMsgQueue(const MQId id, const bool create_or_else_find, ShmType &segment, const int len);
-	ShmMsgQueue(ShmType &segment, const int len);
+	ShmMsgQueue(ShmType &segment, const MQId id, const int len);
+	ShmMsgQueue(ShmType &segment, const bool create_or_else_find, const MQId id, const int len);
+	ShmMsgQueue(const int64_t abs_addr, ShmType &segment, const MQId id);
 	~ShmMsgQueue();
 	static bool Remove(ShmType &shm, const MQId id);
 	MQId Id() const { return id_; }
 	ShmType &shm() const { return queue_.shm(); }
+	int64_t AbsAddr() const { return queue_.offset(); }
 
 	bool Recv(RawData &val, const int timeout_ms)
 	{
@@ -73,18 +75,9 @@
 
 	bool Recv(MsgI &msg, const int timeout_ms) { return Recv(msg.OffsetRef(), timeout_ms); }
 	bool TryRecv(MsgI &msg) { return TryRecv(msg.OffsetRef()); }
-	static Queue *Find(ShmType &shm, const MQId remote_id);
-	static bool TrySend(ShmType &shm, const MQId remote_id, const RawData val);
-	static bool TrySend(ShmType &shm, const MQId remote_id, MsgI msg)
-	{
-		bool r = false;
-		msg.AddRef(); // TODO check if we could avoid addref here.
-		DEFER1(if (!r) { msg.Release(); });
-		r = TrySend(shm, remote_id, msg.Offset());
-		return r;
-	}
-	bool TrySend(const MQId remote_id, const MsgI &msg) { return TrySend(shm(), remote_id, msg); }
-	bool TrySend(const MQId remote_id, const RawData val) { return TrySend(shm(), remote_id, val); }
+	static Queue *Find(ShmType &shm, const MQId remote);
+	static bool TrySend(ShmType &shm, const MQInfo &remote, const RawData val);
+	bool TrySend(const MQInfo &remote, const RawData val) { return TrySend(shm(), remote, val); }
 
 private:
 #ifndef BH_USE_ATOMIC_Q

--
Gitblit v1.8.0