diff options
Diffstat (limited to 'test/test_coroutine/test.lua')
| -rw-r--r-- | test/test_coroutine/test.lua | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/test/test_coroutine/test.lua b/test/test_coroutine/test.lua deleted file mode 100644 index c3717a6..0000000 --- a/test/test_coroutine/test.lua +++ /dev/null @@ -1,63 +0,0 @@ - -function printf(s,...) - io.write(s:format(...)) -end - -format_write = function(file, s, ...) - return file:write(s:format(...)) - end - -function test(id) - i = 0 - local j = 1 - while true do - if j % 10000 == 5 and id % 10000 == 5 then - printf("call test, coroutine id: %d, local index: %d, global index: %d\n", id, j, i) - end - j = j + 1 - i = i + 1 - coroutine.yield() - end -end - -function foo(x) - if x % 10000 == 5 then - printf("cal foo: x = %d\n", x) - end - coroutine.yield() -end - -function foo1() - print("call foo1") - foo(10) - return 3 -end - -function main() - n = 10000000 - co_list = {} - for i = n, 1, -1 do - co = coroutine.create(function (i) - foo(i) - end) - table.insert(co_list, co); - end - while(true) do - for i = 1, #co_list do - coroutine.resume(co_list[i], i) - end - end -end - -function lua_call_c() - ---printf("lua: call lua_call_c\n") - t = {"aa", "bb", "cc"} - file = io.open("./output.txt", "a+") - format_write(file, "%s: %d", "age", 12) - ret = myfoo(t) - for k, v in pairs(ret["name"]) do - print(k, v) - end - ---printf("lua: after my_foo\n") -end - |
