summaryrefslogtreecommitdiffstats
path: root/src/DeadlockDetect.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/DeadlockDetect.h')
-rw-r--r--src/DeadlockDetect.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/DeadlockDetect.h b/src/DeadlockDetect.h
index ee97fd6f7..ee6dc3e22 100644
--- a/src/DeadlockDetect.h
+++ b/src/DeadlockDetect.h
@@ -27,10 +27,20 @@ class cDeadlockDetect :
public:
cDeadlockDetect(void);
+ ~cDeadlockDetect();
/** Starts the detection. Hides cIsThread's Start, because we need some initialization */
bool Start(int a_IntervalSec);
+ /** Adds the critical section for tracking.
+ Tracked CSs are listed, together with ownership details, when a deadlock is detected.
+ A tracked CS must be untracked before it is destroyed.
+ a_Name is an arbitrary name that is listed along with the CS in the output. */
+ void TrackCriticalSection(cCriticalSection & a_CS, const AString & a_Name);
+
+ /** Removes the CS from the tracking. */
+ void UntrackCriticalSection(cCriticalSection & a_CS);
+
protected:
struct sWorldAge
{
@@ -44,6 +54,13 @@ protected:
/** Maps world name -> sWorldAge */
typedef std::map<AString, sWorldAge> WorldAges;
+ /** Protects m_TrackedCriticalSections from multithreaded access. */
+ cCriticalSection m_CS;
+
+ /** CriticalSections that are tracked (their status output on deadlock).
+ Protected against multithreaded access by m_CS. */
+ std::vector<std::pair<cCriticalSection *, AString>> m_TrackedCriticalSections;
+
WorldAges m_WorldAges;
/** Number of secods for which the ages must be the same for the detection to trigger */
@@ -63,6 +80,9 @@ protected:
a_WorldName is the name of the world whose age has triggered the detection.
a_WorldAge is the age (in ticks) in which the world is stuck. */
NORETURN void DeadlockDetected(const AString & a_WorldName, Int64 a_WorldAge);
+
+ /** Outputs a listing of the tracked CSs, together with their name and state. */
+ void ListTrackedCSs();
} ;