File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed
cache/src/main/kotlin/com/runetopic/cache/store Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import java.io.Closeable
77import java.math.BigInteger
88import java.nio.ByteBuffer
99import java.nio.file.Path
10+ import java.util.*
1011
1112/* *
1213 * @author Tyler Telis
@@ -19,14 +20,13 @@ class Js5Store(
1920 parallel : Boolean = false
2021) : Closeable {
2122 private var storage = Js5DiskStorage (path, parallel)
22- private val indexes = arrayListOf <Index >()
23+ private val indexes = Collections .synchronizedList <Index >(mutableListOf () )
2324
2425 init {
2526 storage.init (this )
2627 indexes.sortWith(compareBy { it.id })
2728 }
2829
29- @Synchronized
3030 internal fun addIndex (index : Index ) {
3131 indexes.forEach { i -> require(index.id != i.id) { " Index with Id={${index.id} } already exists." } }
3232 indexes.add(index)
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import com.runetopic.cache.store.storage.js5.impl.IdxFile
1111import com.runetopic.cryptography.toWhirlpool
1212import java.io.FileNotFoundException
1313import java.nio.file.Path
14+ import java.util.*
1415import java.util.concurrent.CountDownLatch
1516import java.util.concurrent.Executors
1617import kotlin.io.path.ExperimentalPathApi
@@ -29,7 +30,7 @@ internal class Js5DiskStorage(
2930) : IStorage {
3031 private var masterIdxFile: IIdxFile
3132 private var datFile: IDatFile
32- private var idxFiles: ArrayList <IdxFile > = arrayListOf ( )
33+ private var idxFiles = Collections .synchronizedList <IdxFile >( mutableListOf () )
3334 private val logger = InlineLogger ()
3435
3536 init {
@@ -96,7 +97,6 @@ internal class Js5DiskStorage(
9697 return datFile.readReferenceTable(index.id, getIdxFile(index.id).loadReferenceTable(group.id))
9798 }
9899
99- @Synchronized
100100 private fun getIdxFile (id : Int ): IdxFile {
101101 idxFiles.find { it.id() == id }?.let { return it }
102102 return IdxFile (id, Path .of(" $path /${Constants .MAIN_FILE_IDX }${id} " ))
You can’t perform that action at this time.
0 commit comments