cgeo/c-geo-opensource — Issue #711: Download threads architecture (live map)
Author: samueltardieu
Created: 2011-10-25 07:21:14+00:00
State: open

As of today, when using the live map, we spawn many threads as soon as we move for example. We may try to stop them, but that results in many query in parallel.

The live map cache download thread should be unique, and should use a blocking queue of size 1 to get the next job to do. When the map wants to do a request to gc.com, it will (atomically) empty the 1-place queue then put its request. This way, only the more recent request will be honored by the download threads as soon as the previous request is over.

A prototype downloader thread is visible on https://gist.github.com/1311693 - I've started to use it yesterday with minimal changes to the codebase just to validate the concept and it worked fine. The `Runnable` callback will probably be replaced by a `Message`, but due to the rest of the architecture right now it needs to be signalled to a non-UI (looper) thread.