Creating a thread pool

The next step is to update the dispatcher. Let's make it a thread pool of size 2 and rename it to IO:

val dispatcher = newFixedThreadPoolContext(2, "IO")

Here, we are increasing the size of the pool because asyncFetchHeadlines() is not only fetching the information from the server but also parsing it. This overhead of parsing the XML will affect performance if we use a single thread; sometimes fetching information from one feed can be delayed until the parsing of another is completed.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.246.223