Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[core] Blocking the Map Thread when destroying TileData objects #3724

Closed
wants to merge 5 commits into from

Commits on Apr 15, 2016

  1. [core] Add nonblocking task cancellation

    Add a `::tryCancel()` method to the WorkTask so objects
    that own a WorkTask can try to cancel and if it will block,
    postpone the cancellation.
    
    On debug mode, the RunLoop will print a warning when we are
    blocking trying to cancel tasks on the main thread which we
    should never do.
    tmpsantos authored and jfirebaugh committed Apr 15, 2016
    Configuration menu
    Copy the full SHA
    11d06ed View commit details
    Browse the repository at this point in the history
  2. [core] Make TileData cancellation non-blocking

    We all the time are creating and destroying TileData objects and
    when we try to destroy, we first cancel any ongoing WorkRequest.
    
    When canceling a WorkRequest, there are three scenarios:
    
    - We cancel before the RunLoop queue of the Worker Thread
      executes the task. This should not block the Map Thread.
    
    - We cancel after the work was already executed (but we didn't
      pick the callback yet). This should not block either, the
      bad thing is the work is wasted, but we can live with that.
    
    - We cancel but there is a work ongoing. This is the worse case
      scenario, because we block until the work is completed by the
      Worker Thread. This is a design choice because the Worker might
      share objects with the producer thread. It gets worse if for
      the particular device, parsing is slow.
    
    This new method `::tryCancel` will return false if canceling is
    not possible without blocking, so we can defer.
    tmpsantos authored and jfirebaugh committed Apr 15, 2016
    Configuration menu
    Copy the full SHA
    1a5c34c View commit details
    Browse the repository at this point in the history
  3. [core] Make TileData observable

    Emit notifications when the work is completed. This will be
    used by the next patch.
    tmpsantos authored and jfirebaugh committed Apr 15, 2016
    Configuration menu
    Copy the full SHA
    97b14d4 View commit details
    Browse the repository at this point in the history
  4. [core] Add a custom deleter for the TileData

    We cannot simply delete the TileData at will because
    it might block. The custom deleter makes sure that
    it will only delete the object when it is non-blocking.
    tmpsantos authored and jfirebaugh committed Apr 15, 2016
    Configuration menu
    Copy the full SHA
    12471d8 View commit details
    Browse the repository at this point in the history
  5. Fix build

    jfirebaugh committed Apr 15, 2016
    Configuration menu
    Copy the full SHA
    e3a4a03 View commit details
    Browse the repository at this point in the history