mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 19:44:05 +09:00
new thread pooling strategy and test program WIP
This commit is contained in:
@@ -869,7 +869,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
}
|
||||
|
||||
private fun insertionSortLastElemAV(arr: ArrayList<ActorWithBody>) { // out-projection doesn't work, duh
|
||||
lock(ReentrantLock()) {
|
||||
ReentrantLock().lock {
|
||||
var j = arr.lastIndex - 1
|
||||
val x = arr.last()
|
||||
while (j >= 0 && arr[j] > x) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex.ITEM_DYNAMIC
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex.ITEM_WALLS
|
||||
import net.torvald.terrarum.itemproperties.ItemID
|
||||
import net.torvald.terrarum.lock
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import java.util.*
|
||||
import java.util.concurrent.locks.Lock
|
||||
@@ -253,7 +254,7 @@ class ActorInventory(val actor: Pocketed, var maxCapacity: Int, var capacityMode
|
||||
return itemList[index]
|
||||
}
|
||||
private fun insertionSortLastElem(arr: ArrayList<InventoryPair>) {
|
||||
lock(ReentrantLock()) {
|
||||
ReentrantLock().lock {
|
||||
var j = arr.lastIndex - 1
|
||||
val x = arr.last()
|
||||
while (j >= 0 && arr[j].item > x.item) {
|
||||
@@ -284,15 +285,6 @@ class ActorInventory(val actor: Pocketed, var maxCapacity: Int, var capacityMode
|
||||
}
|
||||
return -(low + 1) // key not found
|
||||
}
|
||||
inline fun lock(lock: Lock, body: () -> Unit) {
|
||||
lock.lock()
|
||||
try {
|
||||
body()
|
||||
}
|
||||
finally {
|
||||
lock.unlock()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data class InventoryPair(val item: GameItem, var amount: Int)
|
||||
@@ -76,8 +76,8 @@ object WorldSimulator {
|
||||
fun moveFluids(delta: Float) {
|
||||
makeFluidMapFromWorld()
|
||||
|
||||
//simCompression()
|
||||
for (y in 1 until fluidMap.size - 1) {
|
||||
simCompression()
|
||||
/*for (y in 1 until fluidMap.size - 1) {
|
||||
for (x in 1 until fluidMap[0].size - 1) {
|
||||
val worldX = x + updateXFrom
|
||||
val worldY = y + updateYFrom
|
||||
@@ -98,7 +98,7 @@ object WorldSimulator {
|
||||
fluidNewMap[y + 1][x] += remainingMass
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
fluidmapToWorld()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user