Skip to content

Commit

Permalink
Add a notice about Linux thread limit.
Browse files Browse the repository at this point in the history
  • Loading branch information
toxicity188 committed Nov 20, 2024
1 parent 858d66f commit 63860dc
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions dist/src/main/kotlin/kr/toxicity/hud/util/Lists.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,24 @@ fun <T> List<T>.forEachAsync(block: (T) -> Unit) {
}
queue
}
val pool = Executors.newFixedThreadPool(tasks.size)
CompletableFuture.allOf(
*tasks.map {
CompletableFuture.runAsync({
it()
}, pool)
}.toTypedArray()
).join()
try {
Executors.newFixedThreadPool(tasks.size).use { pool ->
CompletableFuture.allOf(
*tasks.map {
CompletableFuture.runAsync({
it()
}, pool)
}.toTypedArray()
).join()
}
} catch (error: OutOfMemoryError) {
warn(
"Async task failed!",
"You have to set your Linux max thread limit!",
"",
"Stack trace:",
error.stackTraceToString()
)
}
}
}

0 comments on commit 63860dc

Please sign in to comment.