From d830dc9ba6bbcae328723d94f6b8a0c1829fe850 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Wed, 27 Nov 2024 15:11:42 +0800 Subject: [PATCH] update --- mutex.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mutex.cpp b/mutex.cpp index 225c1a4..f67cc3c 100644 --- a/mutex.cpp +++ b/mutex.cpp @@ -10,16 +10,15 @@ zmutex::zmutex(const char* name) { this->name = name; } zmutex::~zmutex() { vSemaphoreDelete(recursiveMutex); } void zmutex::init() { recursiveMutex = xSemaphoreCreateRecursiveMutex(); - ZASSERT(recursiveMutex != NULL); + ZASSERT_INFO(recursiveMutex != NULL, "zmutex (%s) init failed", name); } bool zmutex::isInit() { return recursiveMutex != NULL; } void zmutex::lock() { // ZASSERT(recursiveMutex != NULL); - if (recursiveMutex == NULL) { - ZLOGE(TAG, "%s recursiveMutex NULL, init it", name); - ZASSERT(recursiveMutex != NULL); - } + + ZASSERT_INFO(recursiveMutex != NULL, "zmutex (%s) not init, init it", name); + xSemaphoreTakeRecursive(recursiveMutex, portMAX_DELAY); } void zmutex::unlock() { xSemaphoreGiveRecursive(recursiveMutex); }