mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-19 12:25:12 -04:00
gui: tick async
This commit is contained in:
parent
00c7097b02
commit
0cc758c864
@ -27,21 +27,28 @@ interface GUIElementDrawer {
|
|||||||
|
|
||||||
fun drawElements(elements: Collection<GUIElement>) {
|
fun drawElements(elements: Collection<GUIElement>) {
|
||||||
val time = TimeUtil.millis
|
val time = TimeUtil.millis
|
||||||
|
val tickLatch = CountUpAndDownLatch(1)
|
||||||
if (time - lastTickTime > ProtocolDefinition.TICK_TIME) {
|
if (time - lastTickTime > ProtocolDefinition.TICK_TIME) {
|
||||||
for (element in elements) {
|
for (element in elements) {
|
||||||
if (!element.enabled) {
|
if (!element.enabled) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
tickLatch.inc()
|
||||||
|
DefaultThreadPool += {
|
||||||
element.tick()
|
element.tick()
|
||||||
if (element is Pollable) {
|
if (element is Pollable) {
|
||||||
if (element.poll()) {
|
if (element.poll()) {
|
||||||
element.apply()
|
element.apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
tickLatch.dec()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lastTickTime = time
|
lastTickTime = time
|
||||||
}
|
}
|
||||||
|
tickLatch.dec()
|
||||||
|
tickLatch.await()
|
||||||
|
|
||||||
val latch = CountUpAndDownLatch(1)
|
val latch = CountUpAndDownLatch(1)
|
||||||
for (element in elements) {
|
for (element in elements) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user