diff options
Diffstat (limited to 'LuaSL')
-rw-r--r-- | LuaSL/testLua/luaprocTest2.lua | 61 |
1 files changed, 29 insertions, 32 deletions
diff --git a/LuaSL/testLua/luaprocTest2.lua b/LuaSL/testLua/luaprocTest2.lua index 7814e42..07a3dc8 100644 --- a/LuaSL/testLua/luaprocTest2.lua +++ b/LuaSL/testLua/luaprocTest2.lua | |||
@@ -11,37 +11,28 @@ if not result then print(error_msg) end | |||
11 | 11 | ||
12 | count = 0 | 12 | count = 0 |
13 | 13 | ||
14 | for i = 1, 10 do | 14 | proc = [=[ |
15 | local proc = [=[ | 15 | require "string" |
16 | require "string" | 16 | local channel = "channel%d" |
17 | local channel = "channel%d" | 17 | local message |
18 | local message | ||
19 | |||
20 | result, error_msg = luaproc.newchannel(channel) | ||
21 | if not result then print(error_msg) end | ||
22 | repeat | ||
23 | message = luaproc.receive(channel) | ||
24 | local x, y = string.find(message, "@") | ||
25 | if not x then | ||
26 | x, y = string.find(message, "@") | ||
27 | x, y = string.find(message, "@") | ||
28 | x, y = string.find(message, "@") | ||
29 | x, y = string.find(message, "@") | ||
30 | x, y = string.find(message, "@") | ||
31 | x, y = string.find(message, "@") | ||
32 | x, y = string.find(message, "@") | ||
33 | x, y = string.find(message, "@") | ||
34 | end | ||
35 | until "quit" == message | ||
36 | ]=] | ||
37 | |||
38 | proc = string.format(proc, i) | ||
39 | -- print(proc) | ||
40 | result, error_msg = luaproc.newproc(proc) | ||
41 | if not result then print(error_msg) else count = count + 1 end | ||
42 | end | ||
43 | 18 | ||
44 | print("Started " .. count .. " Lua threads.") | 19 | result, error_msg = luaproc.newchannel(channel) |
20 | if not result then print(error_msg) end | ||
21 | repeat | ||
22 | message = luaproc.receive(channel) | ||
23 | local x, y = string.find(message, "@") | ||
24 | if not x then | ||
25 | x, y = string.find(message, "@") | ||
26 | x, y = string.find(message, "@") | ||
27 | x, y = string.find(message, "@") | ||
28 | x, y = string.find(message, "@") | ||
29 | x, y = string.find(message, "@") | ||
30 | x, y = string.find(message, "@") | ||
31 | x, y = string.find(message, "@") | ||
32 | x, y = string.find(message, "@") | ||
33 | end | ||
34 | until "quit" == message | ||
35 | ]=] | ||
45 | 36 | ||
46 | mainProc = [=[ | 37 | mainProc = [=[ |
47 | local count = %d | 38 | local count = %d |
@@ -72,8 +63,14 @@ mainProc = [=[ | |||
72 | print("Sent " .. messages .. " messages totalling " .. length .. " bytes. The largest message was " .. #message .. " bytes.") | 63 | print("Sent " .. messages .. " messages totalling " .. length .. " bytes. The largest message was " .. #message .. " bytes.") |
73 | ]=] | 64 | ]=] |
74 | 65 | ||
75 | mainProc = string.format(mainProc, count) | 66 | for i = 1, 10 do |
76 | result, error_msg = luaproc.newproc(mainProc) | 67 | result, error_msg = luaproc.newproc(string.format(proc, i)) |
68 | if not result then print(error_msg) else count = count + 1 end | ||
69 | end | ||
70 | |||
71 | print("Started " .. count .. " Lua threads.") | ||
72 | |||
73 | result, error_msg = luaproc.newproc(string.format(mainProc, count)) | ||
77 | if not result then print(error_msg) end | 74 | if not result then print(error_msg) end |
78 | 75 | ||
79 | luaproc.exit() | 76 | luaproc.exit() |