Reading
Add Comment
CPU- and I/O-bound
CPU bound: This can be work that requires a significant amount of processing of your CPU, for example, the image rendering on your pc
I/O-bound: This can be work that requires heavy duty work to get data which is not stored in your RAM, for example, get data from API or database
Dispatchers:
Dispatchers are a pool of threads
+-----------------------------------+ | Dispatchers.Main | +-----------------------------------+ | Main thread on Android, interact | | with the UI and perform light | | work | +-----------------------------------+ | - Calling suspend functions | | - Call UI functions | | - Updating LiveData | +-----------------------------------+ +-----------------------------------+ | Dispatchers.IO | +-----------------------------------+ | Optimized for disk and network IO | | off the main thread | +-----------------------------------+ | - Database* | | - Reading/writing files | | - Networking** | +-----------------------------------+ +-----------------------------------+ | Dispatchers.Default | +-----------------------------------+ | Optimized for CPU intensive work | | off the main thread | +-----------------------------------+ | - Sorting a list | | - Parsing JSON | | - DiffUtils | +-----------------------------------+
Sources:
android
0 comments:
Post a Comment