mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-07-12 23:14:42 +00:00
Replace mutable HashMap with concurrent TrieMap to hopefully improve thread safety for inventory item operations (#441)
This commit is contained in:
parent
3f2240947b
commit
49fc029c51
1 changed files with 2 additions and 1 deletions
|
|
@ -8,6 +8,7 @@ import net.psforever.types.PlanetSideGUID
|
||||||
|
|
||||||
import scala.annotation.tailrec
|
import scala.annotation.tailrec
|
||||||
import scala.collection.mutable
|
import scala.collection.mutable
|
||||||
|
import scala.collection.concurrent
|
||||||
import scala.util.{Failure, Success, Try}
|
import scala.util.{Failure, Success, Try}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -32,7 +33,7 @@ class GridInventory extends Container {
|
||||||
private var offset : Int = 0 //the effective index of the first cell in the inventory where offset >= 0
|
private var offset : Int = 0 //the effective index of the first cell in the inventory where offset >= 0
|
||||||
|
|
||||||
/* key - an integer (not especially meaningful beyond being unique); value - the card that represents the stowed item */
|
/* key - an integer (not especially meaningful beyond being unique); value - the card that represents the stowed item */
|
||||||
private val items : mutable.HashMap[Int, InventoryItem] = mutable.HashMap[Int, InventoryItem]()
|
private val items : concurrent.TrieMap[Int, InventoryItem] = concurrent.TrieMap[Int, InventoryItem]()
|
||||||
private val entryIndex : AtomicInteger = new AtomicInteger(0)
|
private val entryIndex : AtomicInteger = new AtomicInteger(0)
|
||||||
private var grid : Array[Int] = Array.fill[Int](1)(-1)
|
private var grid : Array[Int] = Array.fill[Int](1)(-1)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue