minimap is working but update is slow

This commit is contained in:
minjaesong
2021-12-16 12:55:21 +09:00
parent b906c41be8
commit ff848c7c3a
11 changed files with 114 additions and 67 deletions

View File

@@ -1,5 +1,7 @@
package net.torvald.terrarum.concurrent
import com.badlogic.gdx.utils.Disposable
import net.torvald.terrarum.App
import java.util.concurrent.*
import kotlin.math.absoluteValue
import kotlin.math.roundToInt
@@ -9,8 +11,9 @@ typealias RunnableFun = () -> Unit
typealias ThreadableFun = (Int) -> Unit
object ThreadExecutor {
val threadCount = Runtime.getRuntime().availableProcessors() // not using (logicalCores + 1) method; it's often better idea to reserve one extra thread for other jobs in the app
class ThreadExecutor(
val threadCount: Int = Runtime.getRuntime().availableProcessors() // not using (logicalCores + 1) method; it's often better idea to reserve one extra thread for other jobs in the app
) {
private lateinit var executor: ExecutorService// = Executors.newFixedThreadPool(threadCount)
val futures = ArrayList<Future<*>>()
private var isOpen = true
@@ -18,6 +21,10 @@ object ThreadExecutor {
var allFinished = true
private set
init {
App.disposables.add(Disposable { this.killAll() })
}
private fun checkShutdown() {
try {
if (executor.isTerminated)