diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2017-09-02 09:45:06 +0200 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2017-09-02 09:50:23 +0200 |
commit | 49c443896dcac8c4eaf08c4024e8bd2366ad899a (patch) | |
tree | b1ec46cab2b4e5731860c7136f1bbfca6fe9d458 /src/DeadlockDetect.cpp | |
parent | SetSwimState now takes into account head height (diff) | |
download | cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.gz cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.bz2 cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.lz cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.xz cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.zst cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.zip |
Diffstat (limited to 'src/DeadlockDetect.cpp')
-rw-r--r-- | src/DeadlockDetect.cpp | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/src/DeadlockDetect.cpp b/src/DeadlockDetect.cpp index 411d452f6..df14e610b 100644 --- a/src/DeadlockDetect.cpp +++ b/src/DeadlockDetect.cpp @@ -56,12 +56,25 @@ bool cDeadlockDetect::Start(int a_IntervalSec) m_IntervalSec = a_IntervalSec; // Read the initial world data: - cRoot::Get()->ForEachWorld([=](cWorld & a_World) + class cFillIn : + public cWorldListCallback + { + public: + cFillIn(cDeadlockDetect * a_Detect) : + m_Detect(a_Detect) + { + } + + virtual bool Item(cWorld * a_World) override { - SetWorldAge(a_World.GetName(), a_World.GetWorldAge()); + m_Detect->SetWorldAge(a_World->GetName(), a_World->GetWorldAge()); return false; } - ); + + protected: + cDeadlockDetect * m_Detect; + } FillIn(this); + cRoot::Get()->ForEachWorld(FillIn); return super::Start(); } @@ -102,12 +115,25 @@ void cDeadlockDetect::Execute(void) while (!m_ShouldTerminate) { // Check the world ages: - cRoot::Get()->ForEachWorld([=](cWorld & a_World) + class cChecker : + public cWorldListCallback + { + public: + cChecker(cDeadlockDetect * a_Detect) : + m_Detect(a_Detect) + { + } + + protected: + cDeadlockDetect * m_Detect; + + virtual bool Item(cWorld * a_World) override { - CheckWorldAge(a_World.GetName(), a_World.GetWorldAge()); + m_Detect->CheckWorldAge(a_World->GetName(), a_World->GetWorldAge()); return false; } - ); + } Checker(this); + cRoot::Get()->ForEachWorld(Checker); std::this_thread::sleep_for(std::chrono::milliseconds(CYCLE_MILLISECONDS)); } // while (should run) |