From 3b93dc0dc34008cf25b2b12f6b026b3d9e4ed623 Mon Sep 17 00:00:00 2001
From: lichao <lichao@aiotlink.com>
Date: 星期五, 30 四月 2021 12:48:14 +0800
Subject: [PATCH] guard shm alloc; rm OnWrite,dup lock in shm queue.

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

diff --git a/src/shm_msg_queue.h b/src/shm_msg_queue.h
index d7b33af..c56784c 100644
--- a/src/shm_msg_queue.h
+++ b/src/shm_msg_queue.h
@@ -46,27 +46,8 @@
 	bool Recv(MsgI &msg, const int timeout_ms) { return queue_.data()->Read(msg, timeout_ms); }
 	bool TryRecv(MsgI &msg) { return queue_.data()->TryRead(msg); }
 	static Queue *Find(SharedMemory &shm, const MQId remote_id);
-	static bool TrySend(SharedMemory &shm, const MQId remote_id, const MsgI &msg, OnSend const &onsend = OnSend());
-	template <class Iter>
-	static int TrySendAll(SharedMemory &shm, const MQId remote_id, const Iter begin, const Iter end, OnSend const &onsend = OnSend())
-	{
-		Queue *remote = Find(shm, remote_id);
-		if (remote) {
-			if (onsend) {
-				return remote->TryWrite(begin, end, [&onsend](const MsgI &msg) { onsend(); msg.AddRef(); });
-			} else {
-				return remote->TryWrite(begin, end, [](const MsgI &msg) { msg.AddRef(); });
-			}
-		} else {
-			// SetLestError(eNotFound);
-			return 0;
-		}
-	}
-
-	template <class... Rest>
-	bool TrySend(const MQId remote_id, Rest const &...rest) { return TrySend(shm(), remote_id, rest...); }
-	template <class... Rest>
-	int TrySendAll(const MQId remote_id, Rest const &...rest) { return TrySendAll(shm(), remote_id, rest...); }
+	static bool TrySend(SharedMemory &shm, const MQId remote_id, MsgI msg);
+	bool TrySend(const MQId remote_id, const MsgI &msg) { return TrySend(shm(), remote_id, msg); }
 
 private:
 	MQId id_;

--
Gitblit v1.8.0