Eric Womer
01/25/2023, 9:11 PMuli
01/27/2023, 1:38 PMEric Womer
01/27/2023, 1:43 PMuli
01/27/2023, 1:53 PMEric Womer
01/27/2023, 1:54 PMuli
01/27/2023, 1:55 PMEric Womer
01/27/2023, 1:55 PMuli
01/27/2023, 1:56 PMEric Womer
01/27/2023, 1:56 PMuli
01/27/2023, 1:58 PMfor (j in i..forCount) {
changes while the loop still itterates.Eric Womer
01/27/2023, 1:58 PMuli
01/27/2023, 2:00 PMval upperBound = forCount
async(Dispatchers.Default) {
for (j in i..upperBound) {
Eric Womer
01/27/2023, 2:00 PMuli
01/27/2023, 2:01 PMEric Womer
01/27/2023, 2:02 PMuli
01/27/2023, 2:14 PM(1 .. (count - remainder) step cores).map { i->
...
...
async {
// innerLoop
}
}.awaitAll().flatten()
And it might be mathematically easier to count through the number of jobs and then calculate the indices belonging to the job:
(0 until cores).map { core->
async {
val i0 = quotent * core
val i1 = quotent * (core + 1) - 1
...
}
}
Eric Womer
01/27/2023, 2:29 PM