This commit is contained in:
DBotThePony 2023-09-29 22:14:01 +07:00
parent ccf696a156
commit b3f7cee963
Signed by: DBot
GPG Key ID: DCC23B5715498507
3 changed files with 20 additions and 18 deletions

View File

@ -4,7 +4,6 @@ import org.apache.logging.log4j.LogManager
import ru.dbotthepony.kstarbound.defs.MovementParameters
import java.util.concurrent.ForkJoinPool
import java.util.concurrent.ForkJoinTask
import java.util.concurrent.Future
import kotlin.reflect.KMutableProperty0
object GlobalDefaults {
@ -50,7 +49,6 @@ object GlobalDefaults {
return listOf(executor.submit {
val line = log.line("Loading global defaults...")
val time = System.nanoTime()
tasks.forEach { it.fork() }
tasks.forEach { it.join() }
line.text = "Loaded global defaults in ${((System.nanoTime() - time) / 1_000_000.0).toLong()}ms"
})

View File

@ -155,7 +155,10 @@ class ObjectRegistry<T : Any>(val clazz: KClass<T>, val name: String, val key: (
return add(RegistryObject(value, json, file), key)
}
private val lock = Any()
private fun add(value: RegistryObject<T>, key: String): Boolean {
synchronized(lock) {
val existing = objects.put(key, value)
if (existing != null) {
@ -174,6 +177,7 @@ class ObjectRegistry<T : Any>(val clazz: KClass<T>, val name: String, val key: (
return existing != null || intExisting != null
}
}
companion object {
private val LOGGER = LogManager.getLogger()

View File

@ -67,7 +67,7 @@ annotation class JsonBuilder
annotation class JsonFactory(
val storesJson: Boolean = false,
val asList: Boolean = false,
val logMisses: Boolean = true,
val logMisses: Boolean = false,
)
/**