Changes

Jump to: navigation, search

Performance/Fenix/Best Practices

2 bytes added, 22:50, 11 May 2021
Dispatchers.Default is not a good default
In general, <code>Dispatchers.Default</code> should only be used for computationally intensive tasks where tasks are FIFO priority or equal priority (this doesn't come up much in Android). It'd be much less misleading if it were named <code>Dispatchers.Computation</code>.
As for what to do if the default dispatcher is not a good fit, there's no one-size-fits-all solution. To choose the right threading schemestrategy, it's important to understand your options: learn what each of the Dispatchers are intended for, what mechanisms they use to manage that, and their implications. Here are some additional considerations:
* <code>Dispatchers.IO</code> is often a much better default choice than the default dispatcher if your code does not produce many simultaneous tasks – which could generate many new threads – because it'll re-use existing threads.
* Avoid creating a dedicated thread or thread pool unless it's strictly necessary: each new thread costs the system resources
If you have questions about what the appropriate threading strategy is, please ask the perf team!
Confirm
975
edits

Navigation menu