Skip to content

Commit ae41672

Browse files
Vixb1122elizarov
authored andcommitted
Update coroutines-guide-ui.md
1 parent fa13beb commit ae41672

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ui/coroutines-guide-ui.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,11 +512,11 @@ suspend fun fib(x: Int): Int = withContext(CommonPool) {
512512
> You can get full code [here](kotlinx-coroutines-javafx/src/test/kotlin/guide/example-ui-blocking-02.kt).
513513
514514
You can run this code and verify that UI is not frozen while large Fibonacci numbers are being computed.
515-
However, this code computes `fib` somewhat slower, because every recursive call to `fib` goes via `run`. This is
516-
not a big problem in practice, because `run` is smart enough to check that the coroutine is already running
515+
However, this code computes `fib` somewhat slower, because every recursive call to `fib` goes via `withContext`. This is
516+
not a big problem in practice, because `withContext` is smart enough to check that the coroutine is already running
517517
in the required context and avoids overhead of dispatching coroutine to a different thread again. It is an
518518
overhead nonetheless, which is visible on this primitive code that does nothing else, but only adds integers
519-
in between invocations to `run`. For some more substantial code, the overhead of an extra `run` invocation is
519+
in between invocations to `withContext`. For some more substantial code, the overhead of an extra `withContext` invocation is
520520
not going to be significant.
521521

522522
Still, this particular `fib` implementation can be made to run as fast as before, but in the background thread, by renaming

0 commit comments

Comments
 (0)