assets verify: fix infinite waiting

This commit is contained in:
Bixilon 2021-12-18 14:57:45 +01:00
parent d12a69974a
commit ba498b35b9
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 5 additions and 3 deletions

View File

@ -113,8 +113,10 @@ class IndexAssetsManager(
val size = data["size"]?.toLong() ?: -1
val hash = data["hash"].toString()
if (tasks.count > DefaultThreadPool.threadCount - 1) {
tasks.waitForChange()
synchronized(tasks.lock) {
if (tasks.count > DefaultThreadPool.threadCount - 1) {
tasks.waitForChange()
}
}
tasks.inc()
DefaultThreadPool += ThreadPoolRunnable(priority = ThreadPool.LOW) {

View File

@ -18,7 +18,7 @@ import de.bixilon.minosoft.util.KUtil.toSynchronizedList
class CountUpAndDownLatch @JvmOverloads constructor(count: Int, var parent: CountUpAndDownLatch? = null) {
private val changeCallbacks: MutableSet<() -> Unit> = mutableSetOf()
private val lock = Object()
val lock = Object()
private val children: MutableSet<CountUpAndDownLatch> = synchronizedSetOf()
private var rawCount = 0
set(value) {