mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 20:05:02 -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>) {
|
||||
val time = TimeUtil.millis
|
||||
val tickLatch = CountUpAndDownLatch(1)
|
||||
if (time - lastTickTime > ProtocolDefinition.TICK_TIME) {
|
||||
for (element in elements) {
|
||||
if (!element.enabled) {
|
||||
continue
|
||||
}
|
||||
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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user