Inspectopedia
 
2024.3

RunBlocking in coroutine

Warning
New
Last modified: 03 December 2024

Reports runBlocking builders that can be reached from coroutines.

Coroutines share threads for execution. When a runBlocking builder is called from a coroutine it blocks the underlying thread and prevents other coroutines from using this resource. This can result in performance issues and in bad cases thread starvation.

It provides a potential callstack from coroutine primitive (suspend function or builder) to runBlocking builder.

Example:

Potential solution:

Use the explore functions with overrides option to configure analysis for virtual functions:

  • Use the No option to skip analysis for a function with overrides.

  • Use the Yes, excluding overrides option to only explore the function in the defined callee type.

  • Use the Yes, including overrides option to explore the function and all overrides.