Class TLcdEarthAsynchronousTileSet
- All Implemented Interfaces:
ILcdEarthTileSet,ILcdBounded,ILcdDisposable,AutoCloseable
ILcdEarthTileSet that can execute produceTile and
updateTile requests asynchronously using an ExecutorService.
By using this wrapper, any existing tileset can be extended with asynchronous operation support.
This simplifies the implementation of custom tilesets.
This tileset is thread-safe for tile reading if the delegate tileset is also thread-safe for tile
reading.- Since:
- 8.2
-
Constructor Summary
ConstructorsConstructorDescriptionTLcdEarthAsynchronousTileSet(ILcdEarthTileSet aDelegate, String aDisplayName) Creates a new asynchronous wrapper around the specified tileset that uses anExecutorServicewith a single thread to produce tiles.TLcdEarthAsynchronousTileSet(ILcdEarthTileSet aDelegate, String aDisplayName, int aNumThreads) Creates a new asynchronous wrapper around the specified tileset that uses anExecutorServicewith the specified number of threads to produce tiles.TLcdEarthAsynchronousTileSet(ILcdEarthTileSet aTileSet, ExecutorService aExecutorService) Constructs a newTLcdEarthAsynchronousExecutorTileSetthat uses the specified executor service to produce tiles.TLcdEarthAsynchronousTileSet(ILcdEarthTileSet aTileSet, ExecutorService aExecutorService, boolean aShutDownExecutorServiceOnDispose) Constructs a newTLcdEarthAsynchronousExecutorTileSetthat uses the specified executor service to produce tiles. -
Method Summary
Modifier and TypeMethodDescriptionvoidcancelTile(int aLevel, long aTileX, long aTileY, ILcdEarthTileSetCoverage aCoverage, ILcdGeoReference aGeoReference, TLcdEarthTileFormat aFormat, ILcdEarthTileSetCallback aCallback, Object aContext) This method should be overridden if theproduceTileand/orupdateTileis overridden and the new implementation calls the implementation of this class using different parameters than passed to it.voiddispose()This will alsoshut downthe executor service depending on theisShutdownExecutorServiceOnDispose()setting and cancel any remaining tasks that were submitted to theExecutorServiceby this tileset.Returns the tile operation mode used on thedelegate tile setwhen producing tiles asynchronously.intReturns the priority of the thread used by this asynchronous tileset if noExecutorServicewas specified in the constructor.booleanWhether executor service will be shut down when this tileset is disposed or not.voidproduceTile(ILcdEarthTileSetCoverage aCoverage, int aLevel, long aTileX, long aTileY, ILcdGeoReference aGeoReference, TLcdEarthTileFormat aFormat, TLcdEarthTileOperationMode aMode, ILcdEarthTileSetCallback aCallback, Object aContext) Produces the requested tile, and invoke the supplied callback when done.voidsetDelegateTileOperationMode(TLcdEarthTileOperationMode aDelegateTileOperationMode) Sets the tile operation mode used on thedelegate tile setwhen producing tiles asynchronously.voidsetPriority(int aNewPriority) Sets the priority of the thread used by this asynchronous tileset.voidupdateTile(ALcdEarthTile aEarthTile, TLcdEarthTileOperationMode aMode, ILcdEarthTileSetCallback aCallback, Object aContext) Produces an updated version of the given tile, if necessary.Methods inherited from class com.luciad.earth.tileset.util.ALcdEarthTileSetWrapper
containsTile, containsTileSetCoverage, getBounds, getDelegateTileSet, getLevelCount, getTileColumnCount, getTileRowCount, getTileSetCoverage, getTileSetCoverage, getTileSetCoverageCount, isFormatSupported, isGeoReferenceSupported, produceTile, updateTileMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.luciad.util.ILcdDisposable
close
-
Constructor Details
-
TLcdEarthAsynchronousTileSet
Creates a new asynchronous wrapper around the specified tileset that uses anExecutorServicewith a single thread to produce tiles. The display name parameter is used to name the thread created by this tileset.- Parameters:
aDelegate- the tileset to be wrappedaDisplayName- the name to be used for the worker thread
-
TLcdEarthAsynchronousTileSet
public TLcdEarthAsynchronousTileSet(ILcdEarthTileSet aDelegate, String aDisplayName, int aNumThreads) Creates a new asynchronous wrapper around the specified tileset that uses anExecutorServicewith the specified number of threads to produce tiles. The display name parameter is used to name the threads created by this tileset.- Parameters:
aDelegate- the tileset to be wrappedaDisplayName- the name to be used for the worker threadaNumThreads- the number of threads to use
-
TLcdEarthAsynchronousTileSet
Constructs a newTLcdEarthAsynchronousExecutorTileSetthat uses the specified executor service to produce tiles. The specified executor service will be shut down when this tileset is disposed.- Parameters:
aTileSet- the delegate tilesetaExecutorService- the executor service- See Also:
-
TLcdEarthAsynchronousTileSet
public TLcdEarthAsynchronousTileSet(ILcdEarthTileSet aTileSet, ExecutorService aExecutorService, boolean aShutDownExecutorServiceOnDispose) Constructs a newTLcdEarthAsynchronousExecutorTileSetthat uses the specified executor service to produce tiles.- Parameters:
aTileSet- the delegate tilesetaExecutorService- the executor serviceaShutDownExecutorServiceOnDispose- whetheraExecutorServicewill be shut down when this tileset is disposed or not- See Also:
-
-
Method Details
-
isShutdownExecutorServiceOnDispose
public boolean isShutdownExecutorServiceOnDispose()Whether executor service will be shut down when this tileset is disposed or not.- Returns:
- true if the executor service will be shut down when this tileset is disposed; false otherwise
- See Also:
-
setPriority
public void setPriority(int aNewPriority) Sets the priority of the thread used by this asynchronous tileset. This method has no effect if anExecutorServicewas specified in the constructor.- Parameters:
aNewPriority- a priority value accepted byjava.lang.Thread#setPriority()
-
getPriority
public int getPriority()Returns the priority of the thread used by this asynchronous tileset if noExecutorServicewas specified in the constructor. Otherwise an invalid priority is returned.- Returns:
- a priority value accepted by
java.lang.Thread#setPriority()if noExecutorServicewas specified in the constructor. Otherwise an invalid priority is returned.
-
setDelegateTileOperationMode
Sets the tile operation mode used on thedelegate tile setwhen producing tiles asynchronously. If the delegate mode is set toTLcdEarthTileOperationMode.PREFER_ASYNCHRONOUSthen the tile production may (partially) occur on other threads then those of this tile set. Otherwise, if the mode is set toTLcdEarthTileOperationMode.FORCE_SYNCHRONOUSthen the tile production can only occur on the threads of this tile set. This can for example be used to ensure full control on the threading from a singleExecutorService. The default value isTLcdEarthTileOperationMode.PREFER_ASYNCHRONOUS.- Parameters:
aDelegateTileOperationMode- the tile operation mode
-
getDelegateTileOperationMode
Returns the tile operation mode used on thedelegate tile setwhen producing tiles asynchronously.- Returns:
- the tile operation mode
- See Also:
-
produceTile
public void produceTile(ILcdEarthTileSetCoverage aCoverage, int aLevel, long aTileX, long aTileY, ILcdGeoReference aGeoReference, TLcdEarthTileFormat aFormat, TLcdEarthTileOperationMode aMode, ILcdEarthTileSetCallback aCallback, Object aContext) Description copied from interface:ILcdEarthTileSetProduces the requested tile, and invoke the supplied callback when done. The resulting tile is passed to the call back'stileAvailable()method. If the tile cannot be produced for some reason, the methodtileNotAvailable()should be called instead.If the tileset supports it and
aModeisTLcdEarthTileOperationMode.PREFER_ASYNCHRONOUS, the tile request may be executed asynchronously. However, the callback must be invoked at some point in time, unless thecancelTile()method is used to cancel the tile request before it is executed. IfaModeisTLcdEarthTileOperationMode.FORCE_SYNCHRONOUS, the request must be executed synchronously and the callback must be invoked beforeproduceTile()returns.Tiles may be requested in reference systems other than the native geo reference of the underlying data, provided that the
isGeoReferenceSupported()method returns true for the requested reference. If this is not the case, the tileset should calltileNotAvailable(). If the tileset callstileAvailable(), the geo reference of the resulting tile must be equal toaGeoReference, and the tile's bounds must likewise be expressed in this reference.Similarly, tiles may be requested in different data formats, as described by
TLcdEarthTileFormat. The format determines the type of the data object that will be contained in the requested tile. To check if a format is supported, useisFormatSupported(). If the specified format is not supported, the tileset should calltileNotAvailable().The context parameter may be used to pass application-specific data into the tileset. If it is not needed, its value may be
null.- Specified by:
produceTilein interfaceILcdEarthTileSet- Overrides:
produceTilein classALcdEarthTileSetWrapper- Parameters:
aCoverage- the coverage from which the tile is requestedaLevel- the level from which the tile is requestedaTileX- the column index of the requested tileaTileY- the row index of the requested tileaGeoReference- the reference system in which the tile should be returnedaFormat- the desired format of the tile's dataaMode- controls the synchronous or asynchronous behaviour of the tilesetaCallback- will be invoked when the tile is available to be usedaContext- application-specific data to be used by the tileset, if any
-
updateTile
public void updateTile(ALcdEarthTile aEarthTile, TLcdEarthTileOperationMode aMode, ILcdEarthTileSetCallback aCallback, Object aContext) Description copied from interface:ILcdEarthTileSetProduces an updated version of the given tile, if necessary. Produces the same tile if the given tile is up to date.- Specified by:
updateTilein interfaceILcdEarthTileSet- Overrides:
updateTilein classALcdEarthTileSetWrapper- Parameters:
aEarthTile- tile to checkaMode- controls the synchronous or asynchronous behaviour of the tilesetaCallback- will be invoked when the tile is available to be usedaContext- application-specific data to be used by the tileset, if any
-
cancelTile
public void cancelTile(int aLevel, long aTileX, long aTileY, ILcdEarthTileSetCoverage aCoverage, ILcdGeoReference aGeoReference, TLcdEarthTileFormat aFormat, ILcdEarthTileSetCallback aCallback, Object aContext) Description copied from class:ALcdEarthTileSetWrapperThis method should be overridden if theproduceTileand/orupdateTileis overridden and the new implementation calls the implementation of this class using different parameters than passed to it. If the produceTile is overridden assuper.produceTile( myCoverage, aLevel, aTileX, aTileY, aGeoReference, aFormat, aMode, new MyTileSetCallback( aCallback ), aContext );
this method should be overridden assuper.cancelTile( aLevel, aTileX, aTileY, myCoverage, aGeoReference, aFormat, new MyTileSetCallback( aCallback ), aContext );
whereMyTileSetCallbackinstances with the same delegate callback are equal.- Specified by:
cancelTilein interfaceILcdEarthTileSet- Overrides:
cancelTilein classALcdEarthTileSetWrapper- Parameters:
aLevel- the level from which the tile is requestedaTileX- the column index of the requested tileaTileY- the row index of the requested tileaCoverage- the coverage from which the tile is requestedaGeoReference- the reference system in which the tile is requestedaFormat- the format in which the tile is requestedaCallback- would be invoked when the tile would have been available to be usedaContext- application-specific data to be used by the tileset, if any
-
dispose
public void dispose()This will alsoshut downthe executor service depending on theisShutdownExecutorServiceOnDispose()setting and cancel any remaining tasks that were submitted to theExecutorServiceby this tileset.- Specified by:
disposein interfaceILcdDisposable- Specified by:
disposein interfaceILcdEarthTileSet- Overrides:
disposein classALcdEarthTileSetWrapper
-