Skip to content

Commit e357777

Browse files
committed
update
1 parent ac9e09f commit e357777

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

script/service/service.lua

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -143,25 +143,35 @@ end
143143

144144
function m.eventLoop()
145145
pub.task('timer', 1)
146+
pub.on('wakeup', function ()
147+
m.reportStatus()
148+
end)
146149

147-
local function doSomething()
148-
pub.step(false)
149-
if not await.step() then
150-
return false
151-
end
152-
m.sleeping = false
150+
local function busy()
153151
if not m.workingClock then
154152
m.workingClock = time.monotonic()
153+
m.reportStatus()
155154
end
156-
return true
157155
end
158156

159-
local function sleep()
157+
local function idle()
160158
if m.workingClock then
161159
m.workingClock = nil
162-
m.idleClock = time.monotonic()
163160
m.reportStatus()
164161
end
162+
end
163+
164+
local function doSomething()
165+
pub.step(false)
166+
if not await.step() then
167+
return false
168+
end
169+
busy()
170+
return true
171+
end
172+
173+
local function sleep()
174+
idle()
165175
for _ = 1, 10 do
166176
thread.sleep(0.1)
167177
if doSomething() then
@@ -196,9 +206,6 @@ function m.pulse()
196206
-- end
197207
-- m.reportStatus()
198208
--end)
199-
timer.loop(0.1, function ()
200-
m.reportStatus()
201-
end)
202209
timer.loop(1, function ()
203210
fw.update()
204211
end)
@@ -252,7 +259,6 @@ function m.start()
252259
proto.listen()
253260
m.report()
254261
m.pulse()
255-
m.reportStatus()
256262
m.testVersion()
257263

258264
require 'provider'

0 commit comments

Comments
 (0)