mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-02-16 02:20:44 +00:00
minor speed improvements
This commit is contained in:
@@ -183,8 +183,13 @@ public class MantleWriter implements IObjectPlacer, AutoCloseable {
|
||||
Iris.error("Mantle Writer Accessed chunk out of bounds" + cx + "," + cz);
|
||||
return null;
|
||||
}
|
||||
MantleChunk chunk = cachedChunks.computeIfAbsent(Cache.key(cx, cz), k -> mantle.getChunk(cx, cz).use());
|
||||
if (chunk == null) Iris.error("Mantle Writer Accessed " + cx + "," + cz + " and came up null (and yet within bounds!)");
|
||||
final Long key = Cache.key(cx, cz);
|
||||
MantleChunk chunk = cachedChunks.get(key);
|
||||
if (chunk == null) {
|
||||
chunk = mantle.getChunk(cx, cz).use();
|
||||
var old = cachedChunks.put(key, chunk);
|
||||
if (old != null) old.release();
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,13 +7,12 @@ import com.volmit.iris.util.context.ChunkContext
|
||||
import com.volmit.iris.util.documentation.ChunkCoordinates
|
||||
import com.volmit.iris.util.mantle.Mantle
|
||||
import com.volmit.iris.util.mantle.flag.MantleFlag
|
||||
import com.volmit.iris.util.parallel.MultiBurst
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.asCoroutineDispatcher
|
||||
import kotlinx.coroutines.flow.FlowCollector
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
|
||||
interface MatterGenerator {
|
||||
@@ -61,7 +60,7 @@ interface MatterGenerator {
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val dispatcher = Executors.newVirtualThreadPerTaskExecutor().asCoroutineDispatcher()
|
||||
private val dispatcher = MultiBurst.burst.dispatcher
|
||||
private fun CoroutineScope.launch(block: suspend CoroutineScope.() -> Unit) =
|
||||
launch(if (IrisSettings.get().generator.isUseMulticoreMantle) dispatcher else EmptyCoroutineContext, block = block)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user