Skip to content

TileCollector design

peterLaurence edited this page Feb 20, 2020 · 3 revisions

The core design of MapView is the TileCollector. This is the component responsible for asynchronously loading tiles. It uses Kotlin coroutines, Channels and Flow. It's an implementation of Hoare’s CSP (Communicating Sequential Processes) model.

This is the architecture:

MapView

TileCollector interacts with the view-model with two channels:

  • one to receive TileStatuss (a [ReceiveChannel])
  • one to send Tiles (a [SendChannel])

Internally, the "Collector kernel" process incoming TileStatus objects and check whether or not the same request was made recently and is currently in progress. To ensure an overall good performance, this architecture supports back-pressure. So, when the collector is overwhelmed, it cannot processes more tiles and the coroutine that submits TileSpecs in the receive channel gets suspended. It avoids the situation where too much work is submitted to the collector, that further requires a cancellation mechanism. It also receives TileStatus from the workers, which send back those objects when a tile was successfully fetched.

Clone this wiki locally