From 9ecaec865008b764c27aa5476ed7b51d80dbd22b Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Tue, 24 Jan 2012 04:43:09 +1000 Subject: Some test Lua scripts for luaproc and LuaJIT. --- LuaSL/testLua/luaprocTest1.lua | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 LuaSL/testLua/luaprocTest1.lua (limited to 'LuaSL/testLua/luaprocTest1.lua') diff --git a/LuaSL/testLua/luaprocTest1.lua b/LuaSL/testLua/luaprocTest1.lua new file mode 100644 index 0000000..3fe4811 --- /dev/null +++ b/LuaSL/testLua/luaprocTest1.lua @@ -0,0 +1,41 @@ +require "luaproc" + +result, error_msg = luaproc.createworker() +if not result then print(error_msg) end +result, error_msg = luaproc.createworker() +if not result then print(error_msg) end +result, error_msg = luaproc.createworker() +if not result then print(error_msg) end +result, error_msg = luaproc.createworker() +if not result then print(error_msg) end + +result, error_msg = luaproc.newproc( [=[ + + local count = 0 + +-- Hmm, luajit 2 beta 9 crashes at about 8140, lua can go up to 50000 at least. + for i = 1, 8000 do + local channel = "channel" .. i +-- local proc = 'print(luaproc.receive("channel' .. i .. '") .. " " .. ' .. i ..')' + local proc = 'luaproc.receive("' .. channel .. '")' + +-- print(channel .. "\n" .. proc) + result, error_msg = luaproc.newchannel(channel) + if not result then print(error_msg) end + result, error_msg = luaproc.newproc(proc) + if not result then print(error_msg) else count = count + 1 end + end + + print("Started " .. count .. " Lua threads") + + if 0 ~= count then + for i = 1, count do + result, error_msg = luaproc.send("channel" .. i, 'luaproc is working fine! ' .. i) + if not result then print(error_msg .. " " .. i) end + end + end +]=] ) +if not result then print(error_msg .. " for main proc") end + +luaproc.exit() + -- cgit v1.1