From 157530b8b6e11efc5573d5a0db8987a440197aa1 Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 29 Mar 2019 22:28:40 +0800 Subject: *misc --- source/tests/05-physfs/main.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'source/tests') diff --git a/source/tests/05-physfs/main.cpp b/source/tests/05-physfs/main.cpp index b547f1f..4400c44 100644 --- a/source/tests/05-physfs/main.cpp +++ b/source/tests/05-physfs/main.cpp @@ -25,35 +25,43 @@ function main() print(file:GetFileName()) print(file:GetExtension()) print(file:GetName()) - dst = DataBuffer.New(138567) - thread = Thread.New("IO thread") + thread = Thread.New(EThreadType.DEFFERRED) local content = "" local cont = "ok" + if true then + local buff=DataBuffer.New(10) + print(buff:GetSize()) + buff = nil + end local task = IOTask.New("root/physfs2.txt", dst, EIOTaskType.READ, function(db) function _r() print("test..............") local c = db:GetData() - print(c) + print(#c) end function err(msg) print(msg) end xpcall(_r, err) + thread:Stop() end) thread:AddTask(task) - thread:Start() - - print("-------------end-------------") - - print(thread:GetName()) + task = nil + thread:Start() - while(true) do + while true do thread:Post() - Thread.Sleep(100) + Thread.Sleep(100) + local a = io.read() + if a == "x" then + thread:Stop() + end + if thread:IsStopped() then + break + end end - io.read() end function err(msg) @@ -70,7 +78,7 @@ int main(int argc, char* args[]) // 每一个asura程序保存一个lua state,一个虚拟机,一个lua主线程 AEScripting::LuaEnv::Get()->Init(); - Luax::LuaxState& state = LuaEnv::Get()->GetMainLuaxState(); + LUAX_STATE(LuaEnv::Get()->GetMainThread()); state.OpenLibs(); state.PushGlobalNamespace(); -- cgit v1.1-26-g67d0