IndexAssetsManager: properly workaround bad timing issues, GH-6

This commit is contained in:
Bixilon 2022-07-09 19:21:27 +02:00
parent 902c7aef4a
commit 5d69d0bad5
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -115,8 +115,12 @@ class IndexAssetsManager(
val size = data["size"]?.toLong() ?: -1
val hash = data["hash"].toString()
if (tasks.count > DefaultThreadPool.threadCount - 1) {
tasks.waitForChange(100L)
while (tasks.count > DefaultThreadPool.threadCount - 1) {
// ToDo: The timeout is just a workaround for bad multi threading timings
try {
tasks.waitForChange(100L)
} catch (_: InterruptedException) {
}
}
tasks.inc()
DefaultThreadPool += ThreadPoolRunnable(priority = ThreadPool.LOW) {