From b674aecae951c1f83e07f80956160fadf331d026 Mon Sep 17 00:00:00 2001
From: lichao <lichao@aiotlink.com>
Date: 星期四, 03 六月 2021 18:12:33 +0800
Subject: [PATCH] remove useless code, compile warning.

---
 src/bh_util.h     |   53 +++++++-------------------
 src/topic_node.h  |    2 
 src/timed_queue.h |   42 ---------------------
 3 files changed, 15 insertions(+), 82 deletions(-)

diff --git a/src/bh_util.h b/src/bh_util.h
index 15ffeb0..1b7d2c2 100644
--- a/src/bh_util.h
+++ b/src/bh_util.h
@@ -41,8 +41,8 @@
 inline void Put16(void *p, uint16_t u)
 {
 	auto ptr = static_cast<uint8_t *>(p);
-	ptr[0] = (uint8_t)(u >> 8u);
-	ptr[1] = (uint8_t)(u);
+	ptr[0] = (uint8_t) (u >> 8u);
+	ptr[1] = (uint8_t) (u);
 }
 
 inline uint32_t Get32(const void *p)
@@ -56,10 +56,10 @@
 inline void Put32(void *p, uint32_t u)
 {
 	auto ptr = static_cast<uint8_t *>(p);
-	ptr[0] = (uint8_t)(u >> 24u);
-	ptr[1] = (uint8_t)(u >> 16u);
-	ptr[2] = (uint8_t)(u >> 8u);
-	ptr[3] = (uint8_t)(u);
+	ptr[0] = (uint8_t) (u >> 24u);
+	ptr[1] = (uint8_t) (u >> 16u);
+	ptr[2] = (uint8_t) (u >> 8u);
+	ptr[3] = (uint8_t) (u);
 }
 
 inline uint64_t Get64(const void *p)
@@ -77,14 +77,14 @@
 inline void Put64(void *p, uint64_t u)
 {
 	auto ptr = static_cast<uint8_t *>(p);
-	ptr[0] = (uint8_t)(u >> 56);
-	ptr[1] = (uint8_t)(u >> 48);
-	ptr[2] = (uint8_t)(u >> 40u);
-	ptr[3] = (uint8_t)(u >> 32);
-	ptr[4] = (uint8_t)(u >> 24u);
-	ptr[5] = (uint8_t)(u >> 16u);
-	ptr[6] = (uint8_t)(u >> 8u);
-	ptr[7] = (uint8_t)(u);
+	ptr[0] = (uint8_t) (u >> 56);
+	ptr[1] = (uint8_t) (u >> 48);
+	ptr[2] = (uint8_t) (u >> 40u);
+	ptr[3] = (uint8_t) (u >> 32);
+	ptr[4] = (uint8_t) (u >> 24u);
+	ptr[5] = (uint8_t) (u >> 16u);
+	ptr[6] = (uint8_t) (u >> 8u);
+	ptr[7] = (uint8_t) (u);
 }
 
 inline void PutInt(void *p, uint8_t u) { Put8(p, u); }
@@ -143,31 +143,6 @@
 	{
 		Lock lk(mutex_);
 		return f(data_);
-	}
-};
-
-template <class T, class Tag>
-class StaticDataRef
-{
-	typedef T *Ptr;
-	static inline Ptr &ptr()
-	{
-		static Ptr sp(nullptr);
-		return sp;
-	}
-
-protected:
-	static inline T &GetData(const std::string &msg = "Must set data before use!")
-	{
-		if (!ptr()) { throw std::logic_error(msg); }
-		return *ptr();
-	}
-
-public:
-	static bool SetData(T &t)
-	{
-		auto Bind = [&]() { ptr() = &t; return true; };
-		return ptr() ? false : Bind();
 	}
 };
 
diff --git a/src/timed_queue.h b/src/timed_queue.h
index af77b11..51da497 100644
--- a/src/timed_queue.h
+++ b/src/timed_queue.h
@@ -45,46 +45,4 @@
 	Data data_;
 };
 
-template <class Data, class ClockType = std::chrono::steady_clock>
-class TimedQueue
-{
-	typedef TimedData<Data, ClockType> Record;
-
-public:
-	typedef typename Record::Clock Clock;
-	typedef typename Record::TimePoint TimePoint;
-	typedef typename Record::Duration Duration;
-
-private:
-	typedef std::list<Record> Queue;
-	Synced<Queue> queue_;
-
-public:
-	void Push(Data &&data, const TimePoint &expire) { queue_->emplace_back(expire, std::move(data)); }
-	void Push(Data const &data, const TimePoint &expire) { queue_->emplace_back(expire, data); }
-
-	void Push(Data &&data, Duration const &timeout) { Push(std::move(data), Clock::now() + timeout); }
-	void Push(Data const &data, Duration const &timeout) { Push(data, Clock::now() + timeout); }
-
-	template <class Func>
-	void CheckAll(Func const &func)
-	{
-		queue_.Apply([&](Queue &q) {
-			if (q.empty()) {
-				return;
-			}
-			auto it = q.begin();
-			do {
-				if (it->Expired()) {
-					it = q.erase(it);
-				} else if (func(it->data())) {
-					it = q.erase(it);
-				} else {
-					++it;
-				}
-			} while (it != q.end());
-		});
-	}
-};
-
 #endif // end of include guard: TIMED_QUEUE_Y2YLRBS3
diff --git a/src/topic_node.h b/src/topic_node.h
index 8c08fcf..1425844 100644
--- a/src/topic_node.h
+++ b/src/topic_node.h
@@ -163,8 +163,8 @@
 	bool Init();
 	bool Valid() const { return state() != eStateUninited; }
 	std::mutex mutex_;
-	MQId ssn_id_ = 0;
 	std::atomic<State> state_;
+	MQId ssn_id_ = 0;
 	int proc_index_ = -1;
 
 	TopicQueryCache topic_query_cache_;

--
Gitblit v1.8.0