Cuberite
A lightweight, fast and extensible game server for Minecraft
|
#include <DeadlockDetect.h>
Classes | |
struct | sWorldAge |
Public Member Functions | |
cDeadlockDetect () | |
void | Start (int a_IntervalSec) |
Starts the detection. More... | |
void | TrackCriticalSection (cCriticalSection &a_CS, const AString &a_Name) |
Adds the critical section for tracking. More... | |
void | UntrackCriticalSection (cCriticalSection &a_CS) |
Removes the CS from the tracking. More... | |
virtual | ~cDeadlockDetect () override |
Public Member Functions inherited from cIsThread | |
cIsThread (AString &&a_ThreadName) | |
bool | IsCurrentThread (void) const |
Returns true if the thread calling this function is the thread contained within this object. More... | |
void | Start (void) |
Starts the thread; returns without waiting for the actual start. More... | |
void | Stop (void) |
Signals the thread to terminate and waits until it's finished. More... | |
virtual | ~cIsThread () |
Protected Types | |
typedef std::map< AString, sWorldAge > | WorldAges |
Maps world name -> sWorldAge. More... | |
Protected Member Functions | |
void | CheckWorldAge (const AString &a_WorldName, cTickTimeLong a_Age) |
Checks if the world's age has changed, updates the world's stats; calls DeadlockDetected() if deadlock detected. More... | |
void | DeadlockDetected (const AString &a_WorldName, cTickTimeLong a_WorldAge) |
Called when a deadlock is detected in a world. More... | |
virtual void | Execute (void) override |
This function, overloaded by the descendants, is called in the new thread. More... | |
void | ListTrackedCSs () |
Outputs a listing of the tracked CSs, together with their name and state. More... | |
void | SetWorldAge (const AString &a_WorldName, cTickTimeLong a_Age) |
Sets the initial world age. More... | |
Protected Attributes | |
cCriticalSection | m_CS |
Protects m_TrackedCriticalSections from multithreaded access. More... | |
int | m_IntervalSec |
Number of secods for which the ages must be the same for the detection to trigger. More... | |
std::vector< std::pair< cCriticalSection *, AString > > | m_TrackedCriticalSections |
CriticalSections that are tracked (their status output on deadlock). More... | |
WorldAges | m_WorldAges |
Protected Attributes inherited from cIsThread | |
std::atomic< bool > | m_ShouldTerminate |
The overriden Execute() method should check this value periodically and terminate if this is true. More... | |
Private Types | |
using | Super = cIsThread |
Definition at line 23 of file DeadlockDetect.h.
|
private |
Definition at line 26 of file DeadlockDetect.h.
|
protected |
Maps world name -> sWorldAge.
Definition at line 56 of file DeadlockDetect.h.
cDeadlockDetect::cDeadlockDetect | ( | void | ) |
Definition at line 23 of file DeadlockDetect.cpp.
|
overridevirtual |
Definition at line 33 of file DeadlockDetect.cpp.
|
protected |
Checks if the world's age has changed, updates the world's stats; calls DeadlockDetected() if deadlock detected.
Definition at line 129 of file DeadlockDetect.cpp.
|
protected |
Called when a deadlock is detected in a world.
Aborts the server. 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.
Definition at line 159 of file DeadlockDetect.cpp.
|
overrideprotectedvirtual |
This function, overloaded by the descendants, is called in the new thread.
Implements cIsThread.
Definition at line 99 of file DeadlockDetect.cpp.
|
protected |
Outputs a listing of the tracked CSs, together with their name and state.
Definition at line 173 of file DeadlockDetect.cpp.
|
protected |
Sets the initial world age.
Definition at line 119 of file DeadlockDetect.cpp.
void cDeadlockDetect::Start | ( | int | a_IntervalSec | ) |
Starts the detection.
Hides cIsThread's Start, because we need some initialization
Definition at line 54 of file DeadlockDetect.cpp.
void cDeadlockDetect::TrackCriticalSection | ( | cCriticalSection & | a_CS, |
const AString & | a_Name | ||
) |
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.
Definition at line 72 of file DeadlockDetect.cpp.
void cDeadlockDetect::UntrackCriticalSection | ( | cCriticalSection & | a_CS | ) |
Removes the CS from the tracking.
Definition at line 82 of file DeadlockDetect.cpp.
|
protected |
Protects m_TrackedCriticalSections from multithreaded access.
Definition at line 59 of file DeadlockDetect.h.
|
protected |
Number of secods for which the ages must be the same for the detection to trigger.
Definition at line 68 of file DeadlockDetect.h.
|
protected |
CriticalSections that are tracked (their status output on deadlock).
Protected against multithreaded access by m_CS.
Definition at line 63 of file DeadlockDetect.h.
|
protected |
Definition at line 65 of file DeadlockDetect.h.