summaryrefslogtreecommitdiffstats
path: root/src/DeadlockDetect.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2017-01-17 22:38:04 +0100
committerMattes D <github@xoft.cz>2017-01-18 09:03:05 +0100
commit7cc3fb098df221f083da1d81d2327a0a5f22edf5 (patch)
treede9232cbf239800ea1e7a71cf52086509a9472ea /src/DeadlockDetect.h
parentDebuggers: Added a deadlock simulation command. (diff)
downloadcuberite-7cc3fb098df221f083da1d81d2327a0a5f22edf5.tar
cuberite-7cc3fb098df221f083da1d81d2327a0a5f22edf5.tar.gz
cuberite-7cc3fb098df221f083da1d81d2327a0a5f22edf5.tar.bz2
cuberite-7cc3fb098df221f083da1d81d2327a0a5f22edf5.tar.lz
cuberite-7cc3fb098df221f083da1d81d2327a0a5f22edf5.tar.xz
cuberite-7cc3fb098df221f083da1d81d2327a0a5f22edf5.tar.zst
cuberite-7cc3fb098df221f083da1d81d2327a0a5f22edf5.zip
Diffstat (limited to '')
-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();
} ;