Ignore:
Timestamp:
2016-01-19T00:46:03+01:00 (9 years ago)
Author:
wiktorn
Message:

Clear the queue of JMapViewer when panning map and switch to 3-threaded
downloader on default.

See: #josm12396

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java

    r31790 r32007  
    1010import java.util.Map;
    1111import java.util.Map.Entry;
    12 import java.util.concurrent.Executor;
    1312import java.util.concurrent.Executors;
     13import java.util.concurrent.ThreadPoolExecutor;
    1414
    1515import org.openstreetmap.gui.jmapviewer.interfaces.TileJob;
     
    2323 */
    2424public class OsmTileLoader implements TileLoader {
    25     private static final Executor jobDispatcher = Executors.newSingleThreadExecutor();
     25    private static final ThreadPoolExecutor jobDispatcher = (ThreadPoolExecutor) Executors.newFixedThreadPool(3);
    2626
    2727    private final class OsmTileJob implements TileJob {
     
    184184    @Override
    185185    public void cancelOutstandingTasks() {
    186         // intentionally left empty - OsmTileLoader doesn't maintain queue
     186        jobDispatcher.getQueue().clear();
     187    }
     188
     189    /**
     190     * Sets the maximum number of concurrent connections the tile loader will do
     191     * @param num number of conncurent connections
     192     */
     193    public static void setConcurrentConnections(int num) {
     194        jobDispatcher.setMaximumPoolSize(num);
    187195    }
    188196}
Note: See TracChangeset for help on using the changeset viewer.