21 lines
474 B
Kotlin
21 lines
474 B
Kotlin
package io.gitlab.jfronny.inceptum.gtk
|
|
|
|
import io.gitlab.jfronny.inceptum.common.Utils
|
|
import java.util.*
|
|
|
|
private val SCHEDULED: Queue<Runnable> = ArrayDeque()
|
|
|
|
fun schedule(task: Runnable) {
|
|
SCHEDULED.add(task)
|
|
}
|
|
|
|
fun runScheduledTasks() {
|
|
var r: Runnable?
|
|
while (SCHEDULED.poll().also { r = it } != null) {
|
|
try {
|
|
r!!.run()
|
|
} catch (t: Throwable) {
|
|
Utils.LOGGER.error("Could not run scheduled task", t)
|
|
}
|
|
}
|
|
} |