From c0d61292ef6bdd8e2e93525b5df6a8ec5c017c32 Mon Sep 17 00:00:00 2001
From: lichao <lichao@aiotlink.com>
Date: 星期五, 14 五月 2021 14:09:27 +0800
Subject: [PATCH] change refcount, avoid ShmMsgQueue AddRef on send.

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

diff --git a/src/shm_msg_queue.h b/src/shm_msg_queue.h
index 4b7aed8..56ea076 100644
--- a/src/shm_msg_queue.h
+++ b/src/shm_msg_queue.h
@@ -75,14 +75,7 @@
 	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;
-	}
+	static bool TrySend(ShmType &shm, const MQId remote_id, MsgI msg) { return TrySend(shm, remote_id, msg.Offset()); }
 	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); }
 

--
Gitblit v1.8.0