gui: tick async

This commit is contained in:
Bixilon 2022-08-15 11:04:36 +02:00
parent 00c7097b02
commit 0cc758c864
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -27,21 +27,28 @@ interface GUIElementDrawer {
fun drawElements(elements: Collection<GUIElement>) {
val time = TimeUtil.millis
val tickLatch = CountUpAndDownLatch(1)
if (time - lastTickTime > ProtocolDefinition.TICK_TIME) {
for (element in elements) {
if (!element.enabled) {
continue
}
element.tick()
if (element is Pollable) {
if (element.poll()) {
element.apply()
tickLatch.inc()
DefaultThreadPool += {
element.tick()
if (element is Pollable) {
if (element.poll()) {
element.apply()
}
}
tickLatch.dec()
}
}
lastTickTime = time
}
tickLatch.dec()
tickLatch.await()
val latch = CountUpAndDownLatch(1)
for (element in elements) {