From 365c864a587365fe443b11cc0cd7cfc8f8f8eb81 Mon Sep 17 00:00:00 2001
From: lichao <lichao@aiotlink.com>
Date: 星期二, 01 六月 2021 11:19:22 +0800
Subject: [PATCH] refactor, clean up useless code.

---
 src/shm_msg_queue.cpp |   24 ------------------------
 1 files changed, 0 insertions(+), 24 deletions(-)

diff --git a/src/shm_msg_queue.cpp b/src/shm_msg_queue.cpp
index be2d2a2..9db4c6b 100644
--- a/src/shm_msg_queue.cpp
+++ b/src/shm_msg_queue.cpp
@@ -53,22 +53,6 @@
 
 ShmMsgQueue::~ShmMsgQueue() {}
 
-#ifndef BH_USE_ATOMIC_Q
-ShmMsgQueue::Mutex &ShmMsgQueue::GetMutex(const MQId id)
-{
-	static std::unordered_map<MQId, std::shared_ptr<Mutex>> imm;
-
-	static std::mutex mtx;
-	std::lock_guard<std::mutex> lock(mtx);
-	auto pos = imm.find(id);
-	if (pos == imm.end()) {
-		pos = imm.emplace(id, new Mutex(id)).first;
-		// pos = imm.emplace(id, new Mutex()).first;
-	}
-	return *pos->second;
-}
-#endif
-
 bool ShmMsgQueue::Remove(SharedMemory &shm, const MQId id)
 {
 	Queue *q = Find(shm, id);
@@ -95,17 +79,9 @@
 	try {
 		//TODO find from center, or use offset.
 		ShmMsgQueue dest(remote.offset_, shm, remote.id_);
-#ifndef BH_USE_ATOMIC_Q
-		Guard lock(GetMutex(remote_id));
-#endif
 		return dest.queue().TryWrite(val);
 	} catch (...) {
 		// SetLastError(eNotFound, "remote not found");
 		return false;
 	}
 }
-
-// Test shows that in the 2 cases:
-// 1) build msg first, then find remote queue;
-// 2) find remote queue first, then build msg;
-// 1 is about 50% faster than 2, maybe cache related.

--
Gitblit v1.8.0