https://kotlinlang.org logo
#coroutines
Title
# coroutines
u

uli

04/19/2018, 7:39 PM
Here is my code: (updated)
Copy code
while (deferredExports.any { !it.isCompleted && !it.isCompletedExceptionally }) {
                select<Unit> {
                    deferredExports.forEach {
                        if (!it.isCompleted && !it.isCompletedExceptionally) {
                            it.onAwait {
                            }
                        }
                    }
                }
            }
v

Vsevolod Tolstopyatov [JB]

04/20/2018, 8:02 AM
!it.isCompleted && !it.isCompletedExceptionally
is not necessary here in any sense:
await
performs same check and in this code it’s not atomic, so it’s possible to
await
deferred in
Completed
state after checking for
!isCompleted
. Check doesn’t improve neither readability nor performance
u

uli

04/20/2018, 8:14 AM
I know it's broken. But the idea was to not await any deferreds that have already been awaited. I'll check the solution from issue 171 you mentioned below
3 Views