Tame BackgroundRunner: stop running when no more job (#6605)

A BackgroundRunner plugin instance will stop running
(rescheduling a check every 2 seconds) when there is no
(or no more) job to run.
Clients of this service now have to emit an event after
adding a job into PluginShare.backgroundJobs, so an
already loaded but stopped BackgroundRunner can notice
it and start running again.
This commit is contained in:
poire-z
2020-08-31 16:48:29 +02:00
committed by GitHub
parent 0e7f1ba317
commit 962fd02c98
10 changed files with 65 additions and 5 deletions

View File

@@ -26,6 +26,9 @@ function BackgroundTaskPlugin:_schedule(settings_id)
repeated = enabled,
executable = self.executable,
})
local Event = require("ui/event")
local UIManager = require("ui/uimanager")
UIManager:broadcastEvent(Event:new("BackgroundJobsUpdated"))
end
function BackgroundTaskPlugin:_start()