diff options
author | 2016-03-12 12:31:13 +0100 | |
---|---|---|
committer | 2016-03-12 12:31:13 +0100 | |
commit | a026a582f1a0ea8c1ede3acaddacef506ef3f3b0 (patch) | |
tree | e31573822f2359677de519f9f3b600d98e8764cd /3rdparty/luv/examples/uvbook/thread-create.lua | |
parent | 477d2abd43984f076b7e45f5527591fa8fd0d241 (diff) | |
parent | dcab55bf53b94713a6f72e9633f5101c8dd6c08c (diff) |
Merge pull request #15 from mamedev/master
Sync to base master
Diffstat (limited to '3rdparty/luv/examples/uvbook/thread-create.lua')
-rw-r--r-- | 3rdparty/luv/examples/uvbook/thread-create.lua | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/3rdparty/luv/examples/uvbook/thread-create.lua b/3rdparty/luv/examples/uvbook/thread-create.lua deleted file mode 100644 index 4b42587adbf..00000000000 --- a/3rdparty/luv/examples/uvbook/thread-create.lua +++ /dev/null @@ -1,38 +0,0 @@ -local uv = require('luv') - -local step = 10 - -local hare_id = uv.new_thread(function(step,...) - local ffi = require'ffi' - local uv = require('luv') - local sleep - if ffi.os=='Windows' then - ffi.cdef "void Sleep(int ms);" - sleep = ffi.C.Sleep - else - ffi.cdef "unsigned int usleep(unsigned int seconds);" - sleep = ffi.C.usleep - end - while (step>0) do - step = step - 1 - uv.sleep(math.random(1000)) - print("Hare ran another step") - end - print("Hare done running!") -end, step,true,'abcd','false') - -local tortoise_id = uv.new_thread(function(step,...) - local uv = require('luv') - while (step>0) do - step = step - 1 - uv.sleep(math.random(100)) - print("Tortoise ran another step") - end - print("Tortoise done running!") -end,step,'abcd','false') - -print(hare_id==hare_id,uv.thread_equal(hare_id,hare_id)) -print(tortoise_id==hare_id,uv.thread_equal(tortoise_id,hare_id)) - -uv.thread_join(hare_id) -uv.thread_join(tortoise_id) |