diff options
author | worktycho <work.tycho@gmail.com> | 2015-09-29 14:32:30 +0200 |
---|---|---|
committer | worktycho <work.tycho@gmail.com> | 2015-09-29 14:32:30 +0200 |
commit | c76a89fbec7b503aba070e5189c566662231e7b0 (patch) | |
tree | 8ebb9154a78f78ca4d81e39d3c0604afdf0cadf3 /src/Bindings/LuaState.h | |
parent | Merge pull request #2507 from cuberite/LuaStrictStrings (diff) | |
parent | Added LuaState tracker and memory stats logging. (diff) | |
download | cuberite-c76a89fbec7b503aba070e5189c566662231e7b0.tar cuberite-c76a89fbec7b503aba070e5189c566662231e7b0.tar.gz cuberite-c76a89fbec7b503aba070e5189c566662231e7b0.tar.bz2 cuberite-c76a89fbec7b503aba070e5189c566662231e7b0.tar.lz cuberite-c76a89fbec7b503aba070e5189c566662231e7b0.tar.xz cuberite-c76a89fbec7b503aba070e5189c566662231e7b0.tar.zst cuberite-c76a89fbec7b503aba070e5189c566662231e7b0.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Bindings/LuaState.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h index 269a10369..4f688be6c 100644 --- a/src/Bindings/LuaState.h +++ b/src/Bindings/LuaState.h @@ -210,6 +210,9 @@ public: /** Returns true if the m_LuaState is valid */ bool IsValid(void) const { return (m_LuaState != nullptr); } + + /** Returns the name of the subsystem, as specified when the instance was created. */ + AString GetSubsystemName(void) const { return m_SubsystemName; } /** Adds the specified path to package.<a_PathVariable> */ void AddPackagePath(const AString & a_PathVariable, const AString & a_Path); @@ -521,3 +524,37 @@ protected: + +/** Keeps track of all create cLuaState instances. +Can query each for the amount of currently used memory. */ +class cLuaStateTracker +{ +public: + /** Adds the specified Lua state to the internal list of LuaStates. */ + static void Add(cLuaState & a_LuaState); + + /** Deletes the specified Lua state from the internal list of LuaStates. */ + static void Del(cLuaState & a_LuaState); + + /** Returns the statistics for all the registered LuaStates. */ + static AString GetStats(void); + +protected: + typedef cLuaState * cLuaStatePtr; + typedef std::vector<cLuaStatePtr> cLuaStatePtrs; + + /** The internal list of LuaStates. + Protected against multithreaded access by m_CSLuaStates. */ + cLuaStatePtrs m_LuaStates; + + /** Protects m_LuaStates against multithreaded access. */ + cCriticalSection m_CSLuaStates; + + + /** Returns the single instance of this class. */ + static cLuaStateTracker & Get(void); +}; + + + + |