From 62085e1b49ce2d8a630373e410812d5c4a9eecc2 Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 29 Mar 2019 08:56:55 +0800 Subject: *luax --- source/3rd-party/Luax/luax_vm.h | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'source/3rd-party/Luax/luax_vm.h') diff --git a/source/3rd-party/Luax/luax_vm.h b/source/3rd-party/Luax/luax_vm.h index e99d5b5..9039a04 100644 --- a/source/3rd-party/Luax/luax_vm.h +++ b/source/3rd-party/Luax/luax_vm.h @@ -1,6 +1,9 @@ #ifndef __LUAX_CONTEXT_H__ #define __LUAX_CONTEXT_H__ +#include +#include + #include "luax_ref.h" #include "luax_config.h" #include "luax_state.h" @@ -14,22 +17,39 @@ namespace Luax class LuaxVM { public: - LuaxVM(lua_State* L); + LuaxVM(); ~LuaxVM(); void Setup(); - LuaxState state; // lua main state - LuaxRefTable strongRefTable; // strong ref table - LuaxRefTable weakRefTable; // weak ref table + lua_State* CreateThread(); + lua_State* GetMainThread(); + + int GetThreadCount(); + + LuaxRefTable& GetStrongRefTable(); + LuaxRefTable& GetWeakRefTable(); + + bool HasThread(lua_State* L); - size_t objectCount; // 统计所有在此state中创建的实例 + static LuaxVM* TryGetVM(lua_State* L); + + typedef std::map ThreadMap; private: - void SetupRefTables(); + static ThreadMap threadMap; // 通过线程查找虚拟机,为了方便 + + LuaxRefTable mStrongRefTable; // _LUAX_STRONGREF_TABLE + LuaxRefTable mWeakRefTable; // _LUAX_WEAKREF_TABLE + + lua_State* mMainThread; // 主线程 + + std::unordered_set mThreads; // 所有线程 - int mThreadsCount; // 绑定这个context的线程数 +#if LUAX_PROFILER + size_t mObjectCount; // 统计所有在此虚拟机中创建的实例 +#endif }; -- cgit v1.1-26-g67d0