Ticket #15539: v1-0004-TileLoader-add-hasOutstandingTasks-method-to-interfa.patch

File v1-0004-TileLoader-add-hasOutstandingTasks-method-to-interfa.patch, 2.2 KB (added by ris, 8 years ago)
  • TabularUnified src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java

    From faea7eae1b83db332ea41d28682cd0a40f14b2cd Mon Sep 17 00:00:00 2001
    From: Robert Scott <code@humanleg.org.uk>
    Date: Sat, 11 Nov 2017 21:23:44 +0000
    Subject: [PATCH 4/6] TileLoader: add hasOutstandingTasks() method to interface
    
    supplying a default implementation to make the transition easier for
    project-external implementations to adopt - there should be no hard,
    immediate requirement to add an implementation for this method.
    ---
     src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java        |  5 +++++
     .../openstreetmap/gui/jmapviewer/interfaces/TileLoader.java    | 10 ++++++++++
     2 files changed, 15 insertions(+)
    
    diff --git a/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java b/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java
    index 3942dd647..b1dd1b64a 100644
    a b public class OsmTileLoader implements TileLoader {  
    177177    }
    178178
    179179    @Override
     180    public boolean hasOutstandingTasks() {
     181        return jobDispatcher.getTaskCount() > jobDispatcher.getCompletedTaskCount();
     182    }
     183
     184    @Override
    180185    public void cancelOutstandingTasks() {
    181186        jobDispatcher.getQueue().clear();
    182187    }
  • TabularUnified src/org/openstreetmap/gui/jmapviewer/interfaces/TileLoader.java

    diff --git a/src/org/openstreetmap/gui/jmapviewer/interfaces/TileLoader.java b/src/org/openstreetmap/gui/jmapviewer/interfaces/TileLoader.java
    index dcae01773..bc7f4d57e 100644
    a b public interface TileLoader {  
    2626     * to loading = false / loaded = false
    2727     */
    2828    void cancelOutstandingTasks();
     29
     30    /**
     31     * @return whether this {@link TileLoader} has tasks which have not completed. This answer may well be
     32     * "approximate" given that many implementations will be using mechanisms where a queue's state can change
     33     * during the computation.
     34     */
     35    default boolean hasOutstandingTasks() {
     36        // default implementation supplied just to make transition easier for external implementors
     37        throw new UnsupportedOperationException("Not implemented");
     38    }
    2939}