Split off RecursiveMutex from Mutex (#437)

* Split off RecursiveMutex from Mutex

* Fix

* Code quality
This commit is contained in:
Ken Van Hoeylandt
2025-12-28 12:30:54 +01:00
committed by GitHub
parent f48654d3dc
commit 3fc2ff8bc6
45 changed files with 185 additions and 177 deletions
+4 -4
View File
@@ -5,7 +5,7 @@
using namespace tt;
TEST_CASE("a mutex can block a thread") {
auto mutex = Mutex(Mutex::Type::Normal);
auto mutex = Mutex();
mutex.lock(portMAX_DELAY);
Thread thread = Thread(
@@ -30,19 +30,19 @@ TEST_CASE("a mutex can block a thread") {
}
TEST_CASE("a Mutex can be locked exactly once") {
auto mutex = Mutex(Mutex::Type::Normal);
Mutex mutex;
CHECK_EQ(mutex.lock(0), true);
CHECK_EQ(mutex.lock(0), false);
CHECK_EQ(mutex.unlock(), true);
}
TEST_CASE("unlocking a Mutex without locking returns false") {
auto mutex = Mutex(Mutex::Type::Normal);
Mutex mutex;
CHECK_EQ(mutex.unlock(), false);
}
TEST_CASE("unlocking a Mutex twice returns false on the second attempt") {
auto mutex = Mutex(Mutex::Type::Normal);
Mutex mutex;
CHECK_EQ(mutex.lock(0), true);
CHECK_EQ(mutex.unlock(), true);
CHECK_EQ(mutex.unlock(), false);