diff options
author | chai <chaifix@163.com> | 2019-03-29 08:56:55 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-03-29 08:56:55 +0800 |
commit | 62085e1b49ce2d8a630373e410812d5c4a9eecc2 (patch) | |
tree | 5b221e36ff35348aaedc041a2a0513f1d0390ecf /source/3rd-party/Luax/luax_vm.h | |
parent | f4c338c63f3456a8eccd56c35e233843687d55be (diff) |
*luax
Diffstat (limited to 'source/3rd-party/Luax/luax_vm.h')
-rw-r--r-- | source/3rd-party/Luax/luax_vm.h | 34 |
1 files changed, 27 insertions, 7 deletions
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 <map> +#include <unordered_set> + #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<lua_State*, LuaxVM*> ThreadMap; private: - void SetupRefTables(); + static ThreadMap threadMap; // ̲ͨ߳Ϊ˷ + + LuaxRefTable mStrongRefTable; // _LUAX_STRONGREF_TABLE + LuaxRefTable mWeakRefTable; // _LUAX_WEAKREF_TABLE + + lua_State* mMainThread; // ߳ + + std::unordered_set<lua_State*> mThreads; // ߳ - int mThreadsCount; // context߳ +#if LUAX_PROFILER + size_t mObjectCount; // ͳڴдʵ +#endif }; |