diff options
author | chai <chaifix@163.com> | 2019-03-29 00:43:25 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-03-29 00:43:25 +0800 |
commit | f4c338c63f3456a8eccd56c35e233843687d55be (patch) | |
tree | 7278fe4723320c9ef310c5a04d92bf0be1bc778c /source/tests/05-physfs/main.cpp | |
parent | 3bced067a4144381e59ce4bd0eb749eeff5ad1f4 (diff) |
*thread
Diffstat (limited to 'source/tests/05-physfs/main.cpp')
-rw-r--r-- | source/tests/05-physfs/main.cpp | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/source/tests/05-physfs/main.cpp b/source/tests/05-physfs/main.cpp index 28e55e9..14a2745 100644 --- a/source/tests/05-physfs/main.cpp +++ b/source/tests/05-physfs/main.cpp @@ -2,10 +2,12 @@ #include <asura-lib-utils/utils.h> -using namespace Luax; using namespace std; +using namespace AEScripting; string code = R"( +local thread = nil +local dst = nil function main() local suc = Filesystem.Init(arg0) print(suc) @@ -24,6 +26,28 @@ function main() print(file:GetExtension()) print(file:GetName()) + dst = DataBuffer.New(138567) + thread = Thread.New("IO thread") + local content = "" + local cont = "ok" + local task = IOTask.New("root/physfs2.txt", dst, EIOTaskType.READ, function(db) + function _r() + print("test..............") + local c = db:GetData() + print(c) + end + function err(msg) + print(msg) + end + xpcall(_r, err) + end) + thread:AddTask(task) + thread:Start() + + print("-------------end-------------") + + print(thread:GetName()) + io.read() end @@ -38,18 +62,21 @@ int main(int argc, char* args[]) { AsuraEngine::UtilsModule utils; - lua_State* L = LuaxRuntime::Get().Open(); - AEScripting::LuaEnv::Get()->Init(L); - LuaxState& state = LuaxRuntime::Get().GetLuaxState(L); + // ÿһasuraһlua stateһһlua߳ + AEScripting::LuaEnv::Get()->Init(); + + Luax::LuaxState& state = LuaEnv::Get()->GetMainLuaxState(); + state.OpenLibs(); state.PushGlobalNamespace(); if(argc > 0) state.SetField(-1, "arg0", args[0]); utils.Initialize(state); state.PopNamespace(); + state.DoString(code); - LuaxRuntime::Get().Close(L); + LuaEnv::Get()->Exit(); return 0; }
\ No newline at end of file |