mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 11:04:05 +09:00
minimap is working but update is slow
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user