From ed9635582fdf81f490eb630735a1d4027fae9189 Mon Sep 17 00:00:00 2001 From: Hayodea Hekol Date: Tue, 30 Sep 2025 00:32:54 -0400 Subject: [PATCH] Lockvoker: add handleGridlock and invoke it --- include/serializedAsynchronousContinuation.h | 6 ++++-- smocore/serializedAsynchronousContinuation.cpp | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/include/serializedAsynchronousContinuation.h b/include/serializedAsynchronousContinuation.h index 2c63ff8..7ceeb80 100644 --- a/include/serializedAsynchronousContinuation.h +++ b/include/serializedAsynchronousContinuation.h @@ -159,7 +159,8 @@ public: if (!isDeadlock && !isGridlock) { return; } - handleDeadlock(firstFailedQutex); + if (isDeadlock) { handleDeadlock(firstFailedQutex); } + if (isGridlock) { handleGridlock(firstFailedQutex); } #endif return; } @@ -308,7 +309,8 @@ public: * @brief Handle a likely deadlock situation by logging debug information * @param firstFailedQutex The first qutex that failed acquisition */ - void handleDeadlock(Qutex& firstFailedQutex); + void handleDeadlock(Qutex &firstFailedQutex); + void handleGridlock(Qutex &firstFailedQutex); #endif private: diff --git a/smocore/serializedAsynchronousContinuation.cpp b/smocore/serializedAsynchronousContinuation.cpp index 0b86094..9199895 100644 --- a/smocore/serializedAsynchronousContinuation.cpp +++ b/smocore/serializedAsynchronousContinuation.cpp @@ -168,7 +168,7 @@ template void SerializedAsynchronousContinuation ::LockerAndInvoker -::handleDeadlock(Qutex& firstFailedQutex) +::handleDeadlock(Qutex &firstFailedQutex) { std::cerr << __func__ << ": Deadlock: " << "Lockvoker has been waiting for " @@ -179,6 +179,22 @@ SerializedAsynchronousContinuation << " (" << firstFailedQutex.name << ")" << std::endl; } +template +template +void +SerializedAsynchronousContinuation +::LockerAndInvoker +::handleGridlock(Qutex &firstFailedQutex) +{ + std::cerr << __func__ << ": Gridlock: " + << "Lockvoker has been waiting for " + << std::chrono::duration_cast( + std::chrono::steady_clock::now() - this->creationTimestamp) + .count() + << "ms, failed on qutex @" << &firstFailedQutex + << " (" << firstFailedQutex.name << ")" << std::endl; +} + #endif template