Skip to content

Commit

Permalink
add modules: copas, tango, mobdebug into apk
Browse files Browse the repository at this point in the history
  • Loading branch information
Ildar Mulyukov committed Jul 13, 2020
1 parent 7f477c4 commit f28e5d6
Show file tree
Hide file tree
Showing 14 changed files with 3,159 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/src/main/assets/call_in_mainthread.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
-- Helper module for changing call context from a coroutine to the main thread

local mainthread_stash = {}
local yield

local function mainthread_call(f, ...)
yield = yield or (package.loaded["copas"] and package.loaded["copas"].sleep) or coroutine.yield
local thread = coroutine.running()
assert(thread, "cannot call from the main thread")
mainthread_stash[thread] = mainthread_stash[thread] or {}
mainthread_stash[thread].status = nil
mainthread_stash[thread].f = f
mainthread_stash[thread].args = {...}
while mainthread_stash[thread].status == nil do
coroutine.yield()
yield()
end
return mainthread_stash[thread].status, mainthread_stash[thread].res
end
Expand Down
Loading

0 comments on commit f28e5d6

Please sign in to comment.