fix: fix lua invoke c function use main event loop

This commit is contained in:
JuanZoran
2023-03-15 22:12:44 +08:00
parent 53f1998261
commit 3981167d38
8 changed files with 76 additions and 70 deletions

View File

@@ -17,16 +17,14 @@ end
local strategy = {
fallback = function(data, update)
local result = data.result
for _, backend in ipairs(data.backends) do
---@cast backend TransBackend
local name = backend.name
backend.query(data)
if not backend.no_wait then
while result[name] == nil do
update()
end
while result[name] == nil do
update()
end
if type(result[name]) == 'table' then
@@ -55,13 +53,19 @@ local function process(opts)
end
local data = Trans.data.new(opts)
local frontend = data.frontend
Trans.backend.offline.query(data)
local result = data.result['offline']
if not result then
result = strategy[Trans.conf.query](data, data.frontend:wait())
if not result then
-- data.frontend:fallback()
return
end
end
local result = strategy[Trans.conf.query](data, frontend:wait())
if not result then return end
Trans.cache[data.str] = data
frontend:process(data, result)
data.frontend:process(data, result)
end