lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


What are possible alternatives in case I can't get this to work?

You can try my Lua/APR binding, it should work fine on Mac OS X. Here's how I tested it on Linux, the same steps should work for you on a Mac (you may need to install the external dependencies libapr1 and libaprutil1 though):

$ sudo luarocks install lua-apr
$ cat > test.lua
local apr = require 'apr'
print(os.date())
for i = 1, 4 do
  apr.thread(function()
    os.execute('sleep 10 && echo finished_sleeping')
    print(os.date())
  end)
end
$ lua test.lua
Thu Nov 17 20:19:21 2011
Lua/APR joining child thread from __gc() hook ..
finished_sleeping
Thu Nov 17 20:19:31 2011
finished_sleeping
finished_sleeping
Thu Nov 17 20:19:31 2011
Thu Nov 17 20:19:31 2011
finished_sleeping
Thu Nov 17 20:19:31 2011
Lua/APR joining child thread from __gc() hook ..
Lua/APR joining child thread from __gc() hook ..
Lua/APR joining child thread from __gc() hook ..

Hope this helps,

 - Peter