diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-03-28 21:04:07 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-03-28 21:04:07 +0800 |
commit | 1dee813e59166317d993a6010c66e267e69a82c2 (patch) | |
tree | 038c731d4ad82a7de9cfbd4166780d92cf0718a6 /server/src/service.lua | |
parent | ec1806e3b65623e2238bfc3bdb5fc53181074462 (diff) | |
download | lua-language-server-1dee813e59166317d993a6010c66e267e69a82c2.zip |
加快主线程循环速度
Diffstat (limited to 'server/src/service.lua')
-rw-r--r-- | server/src/service.lua | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/server/src/service.lua b/server/src/service.lua index 1145b210..7a6acdb9 100644 --- a/server/src/service.lua +++ b/server/src/service.lua @@ -720,6 +720,7 @@ function mt:listen() local clock = os.clock() while true do + local startClock = os.clock() async.onTick() self:onTick() @@ -730,7 +731,13 @@ function mt:listen() io.stderr:write(err) io.stderr:flush() end - thread.sleep(0.001) + + local passedClock = os.clock() - startClock + if passedClock > 0.1 then + thread.sleep(0.0) + else + thread.sleep(0.001) + end end end |