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 {
|
177 | 177 | } |
178 | 178 | |
179 | 179 | @Override |
| 180 | public boolean hasOutstandingTasks() { |
| 181 | return jobDispatcher.getTaskCount() > jobDispatcher.getCompletedTaskCount(); |
| 182 | } |
| 183 | |
| 184 | @Override |
180 | 185 | public void cancelOutstandingTasks() { |
181 | 186 | jobDispatcher.getQueue().clear(); |
182 | 187 | } |
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 {
|
26 | 26 | * to loading = false / loaded = false |
27 | 27 | */ |
28 | 28 | 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 | } |
29 | 39 | } |