Change update worker to dedicated thread

This commit is contained in:
ceikry 2021-08-08 23:27:49 -05:00
parent 629df5adaf
commit 7e30a30192

View file

@ -32,9 +32,10 @@ class MajorUpdateWorker {
var started = false
val sequence = UpdateSequence()
val sdf = SimpleDateFormat("HHmmss")
fun start() = GlobalScope.launch {
val worker = Thread {
Thread.currentThread().name = "Major Update Worker"
started = true
delay(600L)
Thread.sleep(600L)
while(true){
val start = System.currentTimeMillis()
val rmlist = ArrayList<Pulse>()
@ -94,7 +95,12 @@ class MajorUpdateWorker {
}
val end = System.currentTimeMillis()
delay(max(600 - (end - start), 0))
Thread.sleep(max(600 - (end - start), 0))
}
}
fun start() = {
if(!started){
worker.start()
}
}
}