Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,27 @@
|
|||
function sleeprint(n)
|
||||
local t0 = os.time()
|
||||
while os.time() - t0 <= n do
|
||||
coroutine.yield(false)
|
||||
end
|
||||
print(n)
|
||||
return true
|
||||
end
|
||||
|
||||
coroutines = {}
|
||||
for i=1, #arg do
|
||||
wrapped = coroutine.wrap(sleeprint)
|
||||
table.insert(coroutines, wrapped)
|
||||
wrapped(tonumber(arg[i]))
|
||||
end
|
||||
|
||||
done = false
|
||||
while not done do
|
||||
done = true
|
||||
for i=#coroutines,1,-1 do
|
||||
if coroutines[i]() then
|
||||
table.remove(coroutines, i)
|
||||
else
|
||||
done = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
socket = require 'socket'
|
||||
|
||||
function sleeprint(n)
|
||||
local t0 = socket.gettime()
|
||||
while (socket.gettime() - t0)*100 <= n do
|
||||
coroutine.yield(false)
|
||||
end
|
||||
print(n)
|
||||
return true
|
||||
end
|
||||
|
||||
coroutines = {}
|
||||
for i=1, #arg do
|
||||
wrapped = coroutine.wrap(sleeprint)
|
||||
table.insert(coroutines, wrapped)
|
||||
wrapped(tonumber(arg[i]))
|
||||
end
|
||||
|
||||
done = false
|
||||
while not done do
|
||||
done = true
|
||||
for i=#coroutines,1,-1 do
|
||||
if coroutines[i]() then
|
||||
table.remove(coroutines, i)
|
||||
else
|
||||
done = false
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue