Skip to content

Instantly share code, notes, and snippets.

@ignacio
Created April 2, 2013 15:31
Show Gist options
  • Save ignacio/5293125 to your computer and use it in GitHub Desktop.
Save ignacio/5293125 to your computer and use it in GitHub Desktop.
Another take, but more clumsy.
---
-- Fake synchronous functions
local function Sync(fn)
local function make_resumer(co)
return function(...)
return assert(coroutine.resume(co, ...))
end
end
local co = coroutine.create(fn)
assert( coroutine.resume(co, make_resumer(co), coroutine.yield ) )
end
Sync(function(wait, yield)
for i=1, 10 do
console.log(i)
setTimeout(wait, 1000)
yield()
end
end)
process:loop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment