From a6f67b4249525089fb97eb9418c7014f66c2a000 Mon Sep 17 00:00:00 2001
From: lichao <lichao@aiotlink.com>
Date: 星期三, 28 四月 2021 19:29:17 +0800
Subject: [PATCH] use new robust mutex, circurar; rm timeout mutex.

---
 src/socket.cpp |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/socket.cpp b/src/socket.cpp
index 313c212..2127260 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -24,7 +24,7 @@
 using namespace bhome_msg;
 using namespace bhome_shm;
 
-ShmSocket::ShmSocket(Shm &shm, const MQId &id, const int len) :
+ShmSocket::ShmSocket(Shm &shm, const MQId id, const int len) :
     run_(false), mq_(id, shm, len)
 {
 	Start();
@@ -65,7 +65,8 @@
 					onRecvWithPerMsgCB(*this, imsg, head);
 				}
 			};
-			return mq().TryRecvAll(onMsg) > 0; // this will recv all msgs.
+			MsgI imsg;
+			return mq().TryRecv(imsg) ? (onMsg(imsg), true) : false;
 		};
 
 		try {
@@ -74,6 +75,8 @@
 			if (onIdle) { onIdle(*this); }
 			if (!more_to_send && !more_to_recv) {
 				std::this_thread::yield();
+				using namespace std::chrono_literals;
+				std::this_thread::sleep_for(10000ns);
 			}
 		} catch (...) {
 		}

--
Gitblit v1.8.0