Mercurial > prosody-hg
comparison util/async.lua @ 8927:ed0891383e78
util.async: Copy hooks from main thread into coroutines
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Mon, 25 Jun 2018 13:53:17 +0100 |
| parents | 7a9b680a79fb |
| children | 92f0876b9230 |
comparison
equal
deleted
inserted
replaced
| 8926:89f6b2a2bec3 | 8927:ed0891383e78 |
|---|---|
| 124 local thread = coroutine.create(function (self) -- luacheck: ignore 432/self | 124 local thread = coroutine.create(function (self) -- luacheck: ignore 432/self |
| 125 while true do | 125 while true do |
| 126 func(coroutine.yield("ready", self)); | 126 func(coroutine.yield("ready", self)); |
| 127 end | 127 end |
| 128 end); | 128 end); |
| 129 debug.sethook(thread, debug.gethook()); | |
| 129 assert(coroutine.resume(thread, self)); -- Start it up, it will return instantly to wait for the first input | 130 assert(coroutine.resume(thread, self)); -- Start it up, it will return instantly to wait for the first input |
| 130 return thread; | 131 return thread; |
| 131 end | 132 end |
| 132 | 133 |
| 133 local function default_error_watcher(runner, err) | 134 local function default_error_watcher(runner, err) |
