Search code examples
rx-javarx-androidrxandroidble

Difference between Reactive Schedulers io and computation?


My app uses RxAndroidBle to asynchronously receive data packets from a BLE peripheral, and assembles them into a larger frame. It seems like Schedulers.io() would be appropriate, but we're warned (without explanation) not to do "computation" on an io Scheduler. Does simply copying bytes from one array to another count as "computation"? If so, do I need to create separate Schedulers, one for receiving the data packets and the other for assembling the frames? What would that look like?


Solution

  • Copying bytes from one array to another doesn't count as 'computation', as it is not CPU intensive work (you wait way longer to io then you are doing the memory copying), the computation schedulers designed for CPU intensive work, and its thread count bounded by the cores of the CPU.
    While io schedulers is not thread bound and thus appropriate for io blocking operations.

    You can read detailed explanation on the differences here: rxJava Schedulers Use Cases