From 1fbfef2a51db4a3bac9d8a5b87af94a40a913b7a Mon Sep 17 00:00:00 2001
From: lichao <lichao@aiotlink.com>
Date: 星期日, 25 四月 2021 15:33:40 +0800
Subject: [PATCH] change mqid from uuid to uint64.

---
 utest/api_test.cpp |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/utest/api_test.cpp b/utest/api_test.cpp
index 200ae99..dd59b09 100644
--- a/utest/api_test.cpp
+++ b/utest/api_test.cpp
@@ -151,7 +151,16 @@
 		}
 		st_.nlock_ += n;
 	}
-	void unlock() { mutex_.unlock(); }
+	void unlock()
+	{
+		auto old_time = last_lock_time_.load();
+		if (Now() - old_time > limit_) {
+		} else {
+			if (last_lock_time_.compare_exchange_strong(old_time, Now())) {
+				mutex_.unlock();
+			}
+		}
+	}
 };
 
 namespace
@@ -189,8 +198,8 @@
 
 	const std::string mtx_name("test_mutex");
 	const std::string int_name("test_int");
-	auto mtx = shm.find_or_construct<Mutex>(mtx_name.c_str())();
-	auto pi = shm.find_or_construct<int>(int_name.c_str())(100);
+	auto mtx = shm.FindOrCreate<Mutex>(mtx_name);
+	auto pi = shm.FindOrCreate<int>(int_name, 100);
 
 	printf("mutetx ");
 	PrintPtr(mtx);
@@ -210,7 +219,7 @@
 		TLMutex mutex;
 		// CasMutex mutex;
 		auto Lock = [&]() {
-			for (int i = 0; i < 1000 * 100; ++i) {
+			for (int i = 0; i < 10; ++i) {
 				mutex.lock();
 				mutex.unlock();
 			}

--
Gitblit v1.8.0