diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-08-05 15:24:31 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-08-05 15:24:31 +0800 |
commit | 8fba5c73c5f293020ee4ddba47a535fc06af5faf (patch) | |
tree | fb9cd7105bba58e3a3c97914829a96c51a13ac0b /script/async/async.lua | |
parent | a1ec2fe4db8f611f40eeea2fd4db51d49e6d71ad (diff) | |
download | lua-language-server-8fba5c73c5f293020ee4ddba47a535fc06af5faf.zip |
子线程应当获得文件名
Diffstat (limited to 'script/async/async.lua')
-rw-r--r-- | script/async/async.lua | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/script/async/async.lua b/script/async/async.lua index 023672bf..3db1162c 100644 --- a/script/async/async.lua +++ b/script/async/async.lua @@ -27,14 +27,14 @@ local errlog = thread.channel 'errlog' local gc = thread.channel 'gc' local function task() - local dump, arg = request:bpop() + local dump, path, arg = request:bpop() local env = setmetatable({ IN = request, OUT = response, ERR = errlog, GC = gc, }, { __index = _ENV }) - local f, err = load(dump, '=task', 't', env) + local f, err = load(dump, '@'..path, 't', env) if not f then errlog:push(err .. '\n' .. dump) return @@ -62,7 +62,8 @@ end end local function run(name, arg, callback) - local dump = io.load(ROOT / 'script' / 'async' / (name .. '.lua')) + local path = ROOT / 'script' / 'async' / (name .. '.lua') + local dump = io.load(path) if not dump then error(('找不到[%s]'):format(name)) end @@ -74,7 +75,7 @@ local function run(name, arg, callback) task = task, callback = callback, } - task.request:push(dump, arg) + task.request:push(dump, path:string(), arg) -- TODO 线程回收后禁止外部再使用通道 return task.request, task.response end |