From 77a6c3512a44dfe6540dde71946e6484fe4f173f Mon Sep 17 00:00:00 2001
From: lichao <lichao@aiotlink.com>
Date: 星期一, 10 五月 2021 16:05:28 +0800
Subject: [PATCH] test lock code.

---
 src/shm_queue.h |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/shm_queue.h b/src/shm_queue.h
index 0041f16..5fd14e3 100644
--- a/src/shm_queue.h
+++ b/src/shm_queue.h
@@ -54,6 +54,7 @@
 	}
 	bool TryRead(D &d)
 	{
+		// bhome_shm::Guard lock(mutex_);
 		if (!queue_.empty()) {
 			d = queue_.front();
 			queue_.pop_front();
@@ -64,6 +65,7 @@
 	}
 	bool TryWrite(const D &d)
 	{
+		// bhome_shm::Guard lock(mutex_);
 		if (!queue_.full()) {
 			queue_.push_back(d);
 			return true;
@@ -74,12 +76,16 @@
 
 private:
 	Circular<D> queue_;
+	bhome_shm::Mutex mutex_;
 };
 
 template <int Power = 4>
 class SharedQ63
 {
 public:
+	template <class... T>
+	explicit SharedQ63(T &&...t) {} // easy testing
+
 	typedef int64_t Data;
 	bool Read(Data &d, const int timeout_ms)
 	{

--
Gitblit v1.8.0