summaryrefslogtreecommitdiff
path: root/source/3rd-party/Luax/luax_vm.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/3rd-party/Luax/luax_vm.h')
-rw-r--r--source/3rd-party/Luax/luax_vm.h34
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
};