Why this matters
Avoids repeated, error-prone concurrency code and enforces limits.
Encapsulate coroutine parallelization (map async/awaitAll, limited concurrency) into utilities.
Avoids repeated, error-prone concurrency code and enforces limits.
Side-by-side examples engineers can pattern-match during review.
val results = items.map { async { work(it) } }.map { it.await() } // inline everywheresuspend fun <T,R> parallel(xs: List<T>, limit: Int = 16, f: suspend (T) -> R): List<R> { /*...*/ }
val results = parallel(items) { work(it) }items.map { async{...} }parallel(items) { work(it) }From the same buckets as this rule.