Ignore:
Timestamp:
2015-05-19T20:54:26+02:00 (9 years ago)
Author:
wiktorn
Message:

addresses #11437 - introduce infinite queue for tile loading and clear the queue when user pans the map or changes the zoom. Fixing hosts limit is last problem, thay may incur additional load

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java

    r8389 r8397  
    6363
    6464    public static class LIFOQueue extends LinkedBlockingDeque<Runnable> {
     65        public LIFOQueue() {
     66            super();
     67        }
     68
    6569        public LIFOQueue(int capacity) {
    6670            super(capacity);
     
    9195     * and performance (we do want to have something to offer to worker threads before tasks will be resubmitted by class consumer)
    9296     */
    93     private static Executor DOWNLOAD_JOB_DISPATCHER = new ThreadPoolExecutor(
     97    private static Executor DEFAULT_DOWNLOAD_JOB_DISPATCHER = new ThreadPoolExecutor(
    9498            2, // we have a small queue, so threads will be quickly started (threads are started only, when queue is full)
    9599            THREAD_LIMIT.get().intValue(), // do not this number of threads
     
    114118    private int readTimeout;
    115119    private Map<String, String> headers;
     120    private Executor downloadJobExecutor;
    116121
    117122    /**
     
    120125     * @param readTimeout
    121126     * @param connectTimeout
     127     * @param downloadJobExecutor
    122128     */
    123129    public JCSCachedTileLoaderJob(ICacheAccess<K,V> cache,
    124130            int connectTimeout, int readTimeout,
    125             Map<String, String> headers) {
     131            Map<String, String> headers,
     132            Executor downloadJobExecutor) {
    126133
    127134        this.cache = cache;
     
    130137        this.readTimeout = readTimeout;
    131138        this.headers = headers;
     139        this.downloadJobExecutor = downloadJobExecutor;
     140    }
     141
     142    /**
     143     * @param cache cache instance that we will work on
     144     * @param headers
     145     * @param readTimeout
     146     * @param connectTimeout
     147     */
     148    public JCSCachedTileLoaderJob(ICacheAccess<K, V> cache,
     149            int connectTimeout, int readTimeout,
     150            Map<String, String> headers) {
     151        this(cache, connectTimeout, readTimeout,
     152                headers, DEFAULT_DOWNLOAD_JOB_DISPATCHER);
    132153    }
    133154
     
    240261     */
    241262    protected Executor getDownloadExecutor() {
    242         return DOWNLOAD_JOB_DISPATCHER;
    243     }
    244 
     263        return downloadJobExecutor;
     264    }
    245265
    246266    public void run() {
     
    330350                return true;
    331351            }
     352
    332353            HttpURLConnection urlConn = getURLConnection();
    333354
Note: See TracChangeset for help on using the changeset viewer.