summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-03-29 09:01:36 +0800
committerchai <chaifix@163.com>2019-03-29 09:01:36 +0800
commite37b1dfd022bda4dfdcba243c0543c62c89db32f (patch)
treeeb31ae960809498462c9232c9dc1df392b987fa7
parent62085e1b49ce2d8a630373e410812d5c4a9eecc2 (diff)
*misc
-rw-r--r--build/3rd-party/Luax/Luax.vcxproj2
-rw-r--r--build/3rd-party/Luax/Luax.vcxproj.filters2
-rw-r--r--source/libs/asura-lib-utils/io/io_task.cpp2
-rw-r--r--source/libs/asura-lib-utils/scripting/lua_env.h24
-rw-r--r--source/libs/asura-lib-utils/threading/thread.cpp4
-rw-r--r--source/libs/asura-lib-utils/threading/thread.h2
-rw-r--r--source/tests/05-physfs/main.cpp5
7 files changed, 20 insertions, 21 deletions
diff --git a/build/3rd-party/Luax/Luax.vcxproj b/build/3rd-party/Luax/Luax.vcxproj
index b5730c6..525ba06 100644
--- a/build/3rd-party/Luax/Luax.vcxproj
+++ b/build/3rd-party/Luax/Luax.vcxproj
@@ -131,7 +131,6 @@
<ClInclude Include="..\..\..\Source\3rd-party\Luax\luax_memberref.h" />
<ClInclude Include="..\..\..\Source\3rd-party\Luax\luax_ref.h" />
<ClInclude Include="..\..\..\Source\3rd-party\Luax\luax_reftable.h" />
- <ClInclude Include="..\..\..\Source\3rd-party\Luax\luax_runtime.h" />
<ClInclude Include="..\..\..\Source\3rd-party\Luax\luax_state.h" />
</ItemGroup>
<ItemGroup>
@@ -142,7 +141,6 @@
<ClCompile Include="..\..\..\Source\3rd-party\Luax\luax_memberref.cpp" />
<ClCompile Include="..\..\..\Source\3rd-party\Luax\luax_ref.cpp" />
<ClCompile Include="..\..\..\Source\3rd-party\Luax\luax_reftable.cpp" />
- <ClCompile Include="..\..\..\Source\3rd-party\Luax\luax_runtime.cpp" />
<ClCompile Include="..\..\..\Source\3rd-party\Luax\luax_state.cpp" />
</ItemGroup>
<ItemGroup>
diff --git a/build/3rd-party/Luax/Luax.vcxproj.filters b/build/3rd-party/Luax/Luax.vcxproj.filters
index 7f385fc..c2e6625 100644
--- a/build/3rd-party/Luax/Luax.vcxproj.filters
+++ b/build/3rd-party/Luax/Luax.vcxproj.filters
@@ -6,7 +6,6 @@
<ClInclude Include="..\..\..\Source\3rd-party\Luax\luax_state.h" />
<ClInclude Include="..\..\..\Source\3rd-party\Luax\luax_config.h" />
<ClInclude Include="..\..\..\Source\3rd-party\Luax\luax_reftable.h" />
- <ClInclude Include="..\..\..\Source\3rd-party\Luax\luax_runtime.h" />
<ClInclude Include="..\..\..\Source\3rd-party\Luax\luax_class.hpp" />
<ClInclude Include="..\..\..\Source\3rd-party\Luax\luax_enum.h" />
<ClInclude Include="..\..\..\Source\3rd-party\Luax\luax_cfunctions.h" />
@@ -17,7 +16,6 @@
<ClCompile Include="..\..\..\Source\3rd-party\Luax\luax_ref.cpp" />
<ClCompile Include="..\..\..\Source\3rd-party\Luax\luax_state.cpp" />
<ClCompile Include="..\..\..\Source\3rd-party\Luax\luax_reftable.cpp" />
- <ClCompile Include="..\..\..\Source\3rd-party\Luax\luax_runtime.cpp" />
<ClCompile Include="..\..\..\Source\3rd-party\Luax\luax_enum.cpp" />
<ClCompile Include="..\..\..\Source\3rd-party\Luax\luax_cfunctions.cpp" />
<ClCompile Include="..\..\..\Source\3rd-party\Luax\luax_memberref.cpp" />
diff --git a/source/libs/asura-lib-utils/io/io_task.cpp b/source/libs/asura-lib-utils/io/io_task.cpp
index 7203175..38e21ad 100644
--- a/source/libs/asura-lib-utils/io/io_task.cpp
+++ b/source/libs/asura-lib-utils/io/io_task.cpp
@@ -42,7 +42,7 @@ namespace AsuraEngine
{
if (mCallback)
{
- LuaxScopedState state(LuaEnv::Get()->GetMainState());
+ LuaxScopedState state(LuaEnv::Get()->GetMainThread());
if (PushLuaxMemberRef(state, mCallback))
{
PushLuaxMemberRef(state, mBufferRef);
diff --git a/source/libs/asura-lib-utils/scripting/lua_env.h b/source/libs/asura-lib-utils/scripting/lua_env.h
index 3bef3df..bae6c4c 100644
--- a/source/libs/asura-lib-utils/scripting/lua_env.h
+++ b/source/libs/asura-lib-utils/scripting/lua_env.h
@@ -23,7 +23,7 @@ namespace AsuraEngine
{
public:
- LuaEnv() : mMainState(0) {};
+ LuaEnv() : mVM(0) {};
~LuaEnv() {};
///
@@ -31,25 +31,21 @@ namespace AsuraEngine
///
inline void Init()
{
- ASSERT(!mMainState);
- // ߳
- mMainState = Luax::LuaxRuntime::Get().Open();
- ASSERT(mMainState);
+ ASSERT(!mVM);
+ mVM = new Luax::LuaxVM();
+ ASSERT(mVM);
+ mVM->Setup();
};
- inline lua_State* GetMainState()
+ inline lua_State* GetMainThread()
{
- return mMainState;
- };
-
- inline Luax::LuaxState& GetMainLuaxState()
- {
- return Luax::LuaxRuntime::Get()[mMainState].state;
+ return mVM->GetMainThread();
};
inline void Exit()
{
- Luax::LuaxRuntime::Get().Close(mMainState);
+ delete mVM;
+ mVM = nullptr;
}
private:
@@ -64,7 +60,7 @@ namespace AsuraEngine
/// global_State̹߳˵һ߳lua_newstate()⣬߳lua_newthread()
///
///
- lua_State* mMainState;
+ Luax::LuaxVM* mVM;
};
diff --git a/source/libs/asura-lib-utils/threading/thread.cpp b/source/libs/asura-lib-utils/threading/thread.cpp
index 9c71ace..628eee4 100644
--- a/source/libs/asura-lib-utils/threading/thread.cpp
+++ b/source/libs/asura-lib-utils/threading/thread.cpp
@@ -10,7 +10,7 @@ namespace AsuraEngine
namespace Threading
{
- Thread::Thread(Luax::LuaxState& father, const std::string& name)
+ Thread::Thread(ThreadType type, Luax::LuaxState& luaThread, const std::string& name/* = ""*/)
: mName(name)
{
}
@@ -78,7 +78,7 @@ namespace AsuraEngine
void Thread::Process()
{
- LUAX_STATE(AEScripting::LuaEnv::Get()->GetMainState());
+ LUAX_STATE(AEScripting::LuaEnv::Get()->GetMainThread());
while (!mTaskQueue.empty())
{
Task* task = mTaskQueue.front();
diff --git a/source/libs/asura-lib-utils/threading/thread.h b/source/libs/asura-lib-utils/threading/thread.h
index 3fa079a..3928963 100644
--- a/source/libs/asura-lib-utils/threading/thread.h
+++ b/source/libs/asura-lib-utils/threading/thread.h
@@ -100,11 +100,13 @@ namespace AsuraEngine
LUAX_DECL_METHOD(_GetName);
LUAX_DECL_METHOD(_Sleep);
LUAX_DECL_METHOD(_Post);
+ LUAX_DECL_METHOD(_GetType);
//----------------------------------------------------------------------------//
ThreadImpl* mImpl;
std::string mName;
+ ThreadType mType;
///
/// С
diff --git a/source/tests/05-physfs/main.cpp b/source/tests/05-physfs/main.cpp
index 14a2745..b547f1f 100644
--- a/source/tests/05-physfs/main.cpp
+++ b/source/tests/05-physfs/main.cpp
@@ -48,6 +48,11 @@ function main()
print(thread:GetName())
+ while(true) do
+ thread:Post()
+ Thread.Sleep(100)
+ end
+
io.read()
end