Computation

The Computation Scheduler is similar to the IO Scheduler in that they are both backed by a worker pool. However, the size of the Computation Scheduler's pool is fixed to the number of cores available in the system. Since the amount of available workers is fixed, means that if there are more jobs to run than the count of processors, they will have to wait until a worker becomes available again.

Since this Scheduler is sensitive to running out of workers, as there are only a few of them (most often 2 to 8), it would be a poor fit for IO-based tasks, and especially for network requests. For example, if there are only 2 workers available (quite often the case on phones), it will take only 2 requests to exhaust the pool. If the request takes 3 seconds to complete (and it can, depending on the connection), it means that the Scheduler won't be able to do anything else for at least 3 seconds, and everything else that uses the Computation Scheduler will be put to halt.

However, it is a great fit for calculations that need to be done off the main thread and are relatively quick to be completed. This includes event loops or buses, UI event handling, doing relatively complex math calculations, and similar kinds of work.

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

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