File tree 1 file changed +11
-17
lines changed
kotlinx-coroutines-core/common/src/flow/operators
1 file changed +11
-17
lines changed Original file line number Diff line number Diff line change @@ -464,23 +464,20 @@ private fun <T> Flow<T>.timeoutInternal(
464
464
}
465
465
}
466
466
467
- try {
468
- // Await for values from our producer now
469
- whileSelect {
470
- values.onReceiveOrNull { value ->
471
- if (value != = DONE ) {
472
- if (value == = TIMEOUT ) {
473
- throw InternalFlowTimeoutException ()
474
- }
475
- downStream.emit(NULL .unbox(value))
476
- return @onReceiveOrNull true
467
+ // Await for values from our producer now
468
+ whileSelect {
469
+ values.onReceiveOrNull { value ->
470
+ if (value != = DONE ) {
471
+ if (value == = TIMEOUT ) {
472
+ action(downStream)
473
+ values.cancel(ChildCancelledException ())
474
+ return @onReceiveOrNull false // Just end the loop here. Nothing more to be done.
477
475
}
478
- return @onReceiveOrNull false // We got the DONE signal, so exit the while loop
476
+ downStream.emit(NULL .unbox(value))
477
+ return @onReceiveOrNull true
479
478
}
479
+ return @onReceiveOrNull false // We got the DONE signal, so exit the while loop
480
480
}
481
- } catch (e: InternalFlowTimeoutException ) {
482
- action(downStream)
483
- values.cancel(ChildCancelledException ())
484
481
}
485
482
}
486
483
@@ -501,6 +498,3 @@ internal fun FlowTimeoutException(time: Long) : FlowTimeoutException = FlowTimeo
501
498
502
499
// Special timeout flag
503
500
private val TIMEOUT = Symbol (" TIMEOUT" )
504
-
505
- // Special indicator exception
506
- private class InternalFlowTimeoutException : Exception (" Internal flow timeout exception" )
You can’t perform that action at this time.
0 commit comments