summaryrefslogtreecommitdiff
path: root/script/service/service.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-01-12 17:54:12 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-01-12 17:54:12 +0800
commite357777ba2b01899f2627df101eb6a2b8c7a3553 (patch)
treeccedde031360bb38402d065bea08325242786f82 /script/service/service.lua
parentac9e09ffb7e0dddf7e48725ce59733c53a7443b3 (diff)
downloadlua-language-server-e357777ba2b01899f2627df101eb6a2b8c7a3553.zip
update
Diffstat (limited to 'script/service/service.lua')
-rw-r--r--script/service/service.lua32
1 files changed, 19 insertions, 13 deletions
diff --git a/script/service/service.lua b/script/service/service.lua
index 627388d1..b5e33e25 100644
--- a/script/service/service.lua
+++ b/script/service/service.lua
@@ -143,25 +143,35 @@ end
function m.eventLoop()
pub.task('timer', 1)
+ pub.on('wakeup', function ()
+ m.reportStatus()
+ end)
- local function doSomething()
- pub.step(false)
- if not await.step() then
- return false
- end
- m.sleeping = false
+ local function busy()
if not m.workingClock then
m.workingClock = time.monotonic()
+ m.reportStatus()
end
- return true
end
- local function sleep()
+ local function idle()
if m.workingClock then
m.workingClock = nil
- m.idleClock = time.monotonic()
m.reportStatus()
end
+ end
+
+ local function doSomething()
+ pub.step(false)
+ if not await.step() then
+ return false
+ end
+ busy()
+ return true
+ end
+
+ local function sleep()
+ idle()
for _ = 1, 10 do
thread.sleep(0.1)
if doSomething() then
@@ -196,9 +206,6 @@ function m.pulse()
-- end
-- m.reportStatus()
--end)
- timer.loop(0.1, function ()
- m.reportStatus()
- end)
timer.loop(1, function ()
fw.update()
end)
@@ -252,7 +259,6 @@ function m.start()
proto.listen()
m.report()
m.pulse()
- m.reportStatus()
m.testVersion()
require 'provider'