Ignore:
Timestamp:
2015-07-14T21:58:01+02:00 (6 years ago)
Author:
wiktorn
Message:

Properly handle file based tile sources.

  • move getThreadFactory(String name) to Utils class, so it's easily usable across JOSM
  • rollback changes in [8485]
  • detect that we are working with filesystem TileSource in AbstractTileSourceLayer and if so, do not use JCS as caching mechanism, as tiles are already local
  • change return value of getTileSourceInfo in AbstractTileSourceLayer to AbstractTMSTileSource, as this is anyway - lowest we can work with
  • add test data for testing file base tile sources

closes: #11548

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r8574 r8602  
    4646import java.util.concurrent.ExecutorService;
    4747import java.util.concurrent.Executors;
     48import java.util.concurrent.ThreadFactory;
    4849import java.util.regex.Matcher;
    4950import java.util.regex.Pattern;
     
    13701371     * Returns the initial capacity to pass to the HashMap / HashSet constructor
    13711372     * when it is initialized with a known number of entries.
    1372      * 
     1373     *
    13731374     * When a HashMap is filled with entries, the underlying array is copied over
    13741375     * to a larger one multiple times. To avoid this process when the number of
     
    13871388     * Returns the initial capacity to pass to the HashMap / HashSet constructor
    13881389     * when it is initialized with a known number of entries.
    1389      * 
     1390     *
    13901391     * When a HashMap is filled with entries, the underlying array is copied over
    13911392     * to a larger one multiple times. To avoid this process when the number of
     
    13931394     * given to the HashMap constructor. This method returns a suitable value
    13941395     * that avoids rehashing but doesn't waste memory.
    1395      * 
     1396     *
    13961397     * Assumes default load factor (0.75).
    13971398     * @param nEntries the number of entries expected
     
    14011402        return hashMapInitialCapacity(nEntries, 0.75f);
    14021403    }
     1404
     1405    /**
     1406     * @param name to be set for the threads
     1407     * @return Thread Factory returning named threads
     1408     */
     1409    public static ThreadFactory getNamedThreadFactory(final String name) {
     1410        return new ThreadFactory() {
     1411            @Override
     1412            public Thread newThread(Runnable r) {
     1413                Thread t = Executors.defaultThreadFactory().newThread(r);
     1414                t.setName(name);
     1415                return t;
     1416            }
     1417        };
     1418    }
    14031419}
Note: See TracChangeset for help on using the changeset viewer.