diff options
author | sumneko <sumneko@hotmail.com> | 2019-04-16 17:35:24 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2019-04-16 17:35:24 +0800 |
commit | 74f4749dc840e169ac25b7848f1f882b62388871 (patch) | |
tree | 156231eb46c9a8a821af9326aba6ef34ad4b8fa2 /server/src/async | |
parent | 9fe54198a9a435b70e41dac904d4353b67806ac8 (diff) | |
download | lua-language-server-74f4749dc840e169ac25b7848f1f882b62388871.zip |
加个线程读取本地文件
Diffstat (limited to 'server/src/async')
-rw-r--r-- | server/src/async/loadfile.lua | 12 | ||||
-rw-r--r-- | server/src/async/scanfiles.lua | 8 |
2 files changed, 13 insertions, 7 deletions
diff --git a/server/src/async/loadfile.lua b/server/src/async/loadfile.lua new file mode 100644 index 00000000..e5f270fb --- /dev/null +++ b/server/src/async/loadfile.lua @@ -0,0 +1,12 @@ +require 'utility' +local fs = require 'bee.filesystem' + +while true do + local filename = IN:bpop() + local buf = io.load(fs.path(filename)) + if buf then + OUT:push(filename, buf) + end + collectgarbage() + GC:push(ID, collectgarbage 'count') +end diff --git a/server/src/async/scanfiles.lua b/server/src/async/scanfiles.lua index eb3073df..f54b0866 100644 --- a/server/src/async/scanfiles.lua +++ b/server/src/async/scanfiles.lua @@ -47,13 +47,7 @@ for path in scan(fs.path(args.root), filter) do OUT:push 'stop' return end - local buf = io.load(path) - if buf then - OUT:push('file', { - path = fs.absolute(path):string(), - buf = buf, - }) - end + OUT:push('path', fs.absolute(path):string()) end OUT:push 'ok' |