public class TLcdEarthAsynchronousTileSet extends ALcdEarthTileSetWrapper
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.Constructor and Description |
---|
TLcdEarthAsynchronousTileSet(ILcdEarthTileSet aTileSet,
ExecutorService aExecutorService)
Constructs a new
TLcdEarthAsynchronousExecutorTileSet that uses the specified
executor service to produce tiles. |
TLcdEarthAsynchronousTileSet(ILcdEarthTileSet aTileSet,
ExecutorService aExecutorService,
boolean aShutDownExecutorServiceOnDispose)
Constructs a new
TLcdEarthAsynchronousExecutorTileSet that uses the specified
executor service to produce tiles. |
TLcdEarthAsynchronousTileSet(ILcdEarthTileSet aDelegate,
String aDisplayName)
Creates a new asynchronous wrapper around the specified tileset that uses an
ExecutorService with a single thread to produce tiles. |
TLcdEarthAsynchronousTileSet(ILcdEarthTileSet aDelegate,
String aDisplayName,
int aNumThreads)
Creates a new asynchronous wrapper around the specified tileset that uses an
ExecutorService with the specified number of threads to produce tiles. |
Modifier and Type | Method and Description |
---|---|
void |
cancelTile(int aLevel,
long aTileX,
long aTileY,
ILcdEarthTileSetCoverage aCoverage,
ILcdGeoReference aGeoReference,
TLcdEarthTileFormat aFormat,
ILcdEarthTileSetCallback aCallback,
Object aContext)
This method should be overridden if the
produceTile and/or updateTile is overridden and the new implementation calls the implementation of this
class using different parameters than passed to it. |
void |
dispose()
This will also
shut down the executor
service depending on the isShutdownExecutorServiceOnDispose() setting and cancel any
remaining tasks that were submitted to the ExecutorService by this tileset. |
TLcdEarthTileOperationMode |
getDelegateTileOperationMode()
Returns the tile operation mode used on the
delegate tile set
when producing tiles asynchronously. |
int |
getPriority()
Returns the priority of the thread used by this asynchronous tileset if no
ExecutorService was specified in the constructor. |
boolean |
isShutdownExecutorServiceOnDispose()
Whether executor service will be shut down when this tileset is disposed or not.
|
void |
produceTile(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.
|
void |
setDelegateTileOperationMode(TLcdEarthTileOperationMode aDelegateTileOperationMode)
Sets the tile operation mode used on the
delegate tile set when
producing tiles asynchronously. |
void |
setPriority(int aNewPriority)
Sets the priority of the thread used by this asynchronous tileset.
|
void |
updateTile(ALcdEarthTile aEarthTile,
TLcdEarthTileOperationMode aMode,
ILcdEarthTileSetCallback aCallback,
Object aContext)
Produces an updated version of the given tile, if necessary.
|
containsTile, containsTileSetCoverage, getBounds, getDelegateTileSet, getLevelCount, getTileColumnCount, getTileRowCount, getTileSetCoverage, getTileSetCoverage, getTileSetCoverageCount, isFormatSupported, isGeoReferenceSupported, produceTile, updateTile
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close
public TLcdEarthAsynchronousTileSet(ILcdEarthTileSet aDelegate, String aDisplayName)
ExecutorService
with a single thread to produce tiles. The display name parameter
is used to name the thread created by this tileset.aDelegate
- the tileset to be wrappedaDisplayName
- the name to be used for the worker threadpublic TLcdEarthAsynchronousTileSet(ILcdEarthTileSet aDelegate, String aDisplayName, int aNumThreads)
ExecutorService
with the specified number of threads to produce tiles. The display
name parameter is used to name the threads created by this tileset.aDelegate
- the tileset to be wrappedaDisplayName
- the name to be used for the worker threadaNumThreads
- the number of threads to usepublic TLcdEarthAsynchronousTileSet(ILcdEarthTileSet aTileSet, ExecutorService aExecutorService)
TLcdEarthAsynchronousExecutorTileSet
that uses the specified
executor service to produce tiles. The specified executor service will be shut down when this
tileset is disposed.aTileSet
- the delegate tilesetaExecutorService
- the executor servicedispose()
public TLcdEarthAsynchronousTileSet(ILcdEarthTileSet aTileSet, ExecutorService aExecutorService, boolean aShutDownExecutorServiceOnDispose)
TLcdEarthAsynchronousExecutorTileSet
that uses the specified
executor service to produce tiles.aTileSet
- the delegate tilesetaExecutorService
- the executor serviceaShutDownExecutorServiceOnDispose
- whether aExecutorService
will be shut down when this
tileset is disposed or notdispose()
public boolean isShutdownExecutorServiceOnDispose()
dispose()
public void setPriority(int aNewPriority)
ExecutorService
was specified in the constructor.aNewPriority
- a priority value accepted by java.lang.Thread#setPriority()
public int getPriority()
ExecutorService
was specified in the constructor. Otherwise an invalid priority is
returned.java.lang.Thread#setPriority()
if no
ExecutorService
was specified in the constructor. Otherwise an invalid
priority is returned.public void setDelegateTileOperationMode(TLcdEarthTileOperationMode aDelegateTileOperationMode)
delegate tile set
when
producing tiles asynchronously.
If the delegate mode is set to TLcdEarthTileOperationMode.PREFER_ASYNCHRONOUS
then the
tile production may (partially) occur on other threads then those of this tile set. Otherwise,
if the mode is set to TLcdEarthTileOperationMode.FORCE_SYNCHRONOUS
then 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 single ExecutorService
.
The default value is TLcdEarthTileOperationMode.PREFER_ASYNCHRONOUS
.aDelegateTileOperationMode
- the tile operation modepublic TLcdEarthTileOperationMode getDelegateTileOperationMode()
delegate tile set
when producing tiles asynchronously.setDelegateTileOperationMode(com.luciad.earth.tileset.TLcdEarthTileOperationMode)
public void produceTile(ILcdEarthTileSetCoverage aCoverage, int aLevel, long aTileX, long aTileY, ILcdGeoReference aGeoReference, TLcdEarthTileFormat aFormat, TLcdEarthTileOperationMode aMode, ILcdEarthTileSetCallback aCallback, Object aContext)
ILcdEarthTileSet
tileAvailable()
method. If the tile cannot be produced for some reason, the method tileNotAvailable()
should be called instead.
If the tileset supports it and aMode
is TLcdEarthTileOperationMode.PREFER_ASYNCHRONOUS
,
the tile request may be executed asynchronously. However, the callback
must be invoked at some point in time, unless the
cancelTile()
method is used to cancel the tile request before it is executed. If
aMode
is TLcdEarthTileOperationMode.FORCE_SYNCHRONOUS
,
the request must be executed synchronously and the callback must be
invoked before produceTile()
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 call tileNotAvailable()
. If the tileset
calls tileAvailable()
, the geo reference of the resulting tile
must be equal to aGeoReference
, 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, use isFormatSupported()
.
If the specified format is not supported, the tileset should call
tileNotAvailable()
.
The context parameter may be used to pass application-specific data into
the tileset. If it is not needed, its value may be null
.
produceTile
in interface ILcdEarthTileSet
produceTile
in class ALcdEarthTileSetWrapper
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 anypublic void updateTile(ALcdEarthTile aEarthTile, TLcdEarthTileOperationMode aMode, ILcdEarthTileSetCallback aCallback, Object aContext)
ILcdEarthTileSet
updateTile
in interface ILcdEarthTileSet
updateTile
in class ALcdEarthTileSetWrapper
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 anypublic void cancelTile(int aLevel, long aTileX, long aTileY, ILcdEarthTileSetCoverage aCoverage, ILcdGeoReference aGeoReference, TLcdEarthTileFormat aFormat, ILcdEarthTileSetCallback aCallback, Object aContext)
ALcdEarthTileSetWrapper
produceTile
and/or updateTile
is overridden and the new implementation calls the implementation of this
class using different parameters than passed to it.
If the produceTile is overridden as
super.produceTile( myCoverage, aLevel, aTileX, aTileY, aGeoReference, aFormat, aMode, new MyTileSetCallback( aCallback ), aContext );this method should be overridden as
super.cancelTile( aLevel, aTileX, aTileY, myCoverage, aGeoReference, aFormat, new MyTileSetCallback( aCallback ), aContext );where
MyTileSetCallback
instances with the same delegate callback are equal.cancelTile
in interface ILcdEarthTileSet
cancelTile
in class ALcdEarthTileSetWrapper
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 anypublic void dispose()
shut down
the executor
service depending on the isShutdownExecutorServiceOnDispose()
setting and cancel any
remaining tasks that were submitted to the ExecutorService
by this tileset.dispose
in interface ILcdEarthTileSet
dispose
in interface ILcdDisposable
dispose
in class ALcdEarthTileSetWrapper