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.h |   32 ++------------------------------
 1 files changed, 2 insertions(+), 30 deletions(-)

diff --git a/src/shm_msg_queue.h b/src/shm_msg_queue.h
index 6d922aa..23faa24 100644
--- a/src/shm_msg_queue.h
+++ b/src/shm_msg_queue.h
@@ -25,23 +25,11 @@
 using namespace bhome_shm;
 using namespace bhome_msg;
 
-#define BH_USE_ATOMIC_Q
-
 class ShmMsgQueue
 {
 public:
 	typedef int64_t RawData;
-
-#ifdef BH_USE_ATOMIC_Q
 	typedef ShmObject<SharedQ63<0>> Shmq;
-#else
-	typedef ShmObject<SharedQueue<RawData>> Shmq;
-	// typedef robust::FMutex Mutex;
-	// typedef robust::SemMutex Mutex;
-	typedef robust::NullMutex Mutex;
-	typedef robust::Guard<Mutex> Guard;
-#endif
-
 	typedef Shmq::Data Queue;
 	typedef Shmq::ShmType ShmType;
 	typedef uint64_t MQId;
@@ -55,21 +43,8 @@
 	ShmType &shm() const { return queue_.shm(); }
 	int64_t AbsAddr() const { return queue_.offset(); }
 
-	bool Recv(RawData &val, const int timeout_ms)
-	{
-#ifndef BH_USE_ATOMIC_Q
-		Guard lock(GetMutex(Id()));
-#endif
-		return queue().Read(val, timeout_ms);
-	}
-
-	bool TryRecv(RawData &val)
-	{
-#ifndef BH_USE_ATOMIC_Q
-		Guard lock(GetMutex(Id()));
-#endif
-		return queue().TryRead(val);
-	}
+	bool Recv(RawData &val, const int timeout_ms) { return queue().Read(val, timeout_ms); }
+	bool TryRecv(RawData &val) { return queue().TryRead(val); }
 
 	bool Recv(MsgI &msg, const int timeout_ms) { return Recv(msg.OffsetRef(), timeout_ms); }
 	bool TryRecv(MsgI &msg) { return TryRecv(msg.OffsetRef()); }
@@ -78,9 +53,6 @@
 	bool TrySend(const MQInfo &remote, const RawData val) { return TrySend(shm(), remote, val); }
 
 private:
-#ifndef BH_USE_ATOMIC_Q
-	static Mutex &GetMutex(const MQId id);
-#endif
 	MQId id_;
 	Queue &queue() { return *queue_.data(); }
 	Shmq queue_;

--
Gitblit v1.8.0