public class BigChunkQueue
extends java.lang.Object
BigChunk
asynchronously.Modifier and Type | Class and Description |
---|---|
protected class |
BigChunkQueue.TaskChunkLoad
Responsible for loading chunks.
|
protected class |
BigChunkQueue.TaskChunkSave
Responsible for saving chunks.
|
Modifier and Type | Field and Description |
---|---|
protected MapDataCache |
cache |
protected java.util.Map<BigChunkLocation,java.util.concurrent.Future<BigChunk>> |
loading |
protected java.util.concurrent.ExecutorService |
loadingService |
protected java.io.File |
saveLocation |
protected java.util.Map<BigChunkLocation,java.util.concurrent.Future<java.lang.Boolean>> |
saving |
protected java.util.concurrent.ExecutorService |
savingService |
Constructor and Description |
---|
BigChunkQueue(java.io.File saveFile,
MapDataCache cache)
Construct a BigChunkQueue from the arguments provided.
|
Modifier and Type | Method and Description |
---|---|
protected java.io.File |
getFileFor(BigChunkLocation coord)
Get the file for the
BigChunkLocation . |
boolean |
isLoading(ChunkLocation location) |
boolean |
isSaving(ChunkLocation location) |
void |
load(BigChunkLocation coord)
Load the
BigChunkLocation as soon as possible. |
boolean |
save(BigChunkLocation coord,
BigChunk data)
Save the data as soon as possible, if not being already saved or loaded.
|
boolean |
saveBlocking()
Shutdown loading and saving services, and finish saving what needs to be saved on the main thread.
|
void |
update()
Should be called each tick or so often by whatever is responsible for this
to use the data that has been loaded, and request processing for what has not.
|
protected final java.util.concurrent.ExecutorService savingService
protected final java.util.concurrent.ExecutorService loadingService
protected java.util.Map<BigChunkLocation,java.util.concurrent.Future<BigChunk>> loading
protected java.util.Map<BigChunkLocation,java.util.concurrent.Future<java.lang.Boolean>> saving
protected MapDataCache cache
protected java.io.File saveLocation
public BigChunkQueue(java.io.File saveFile, MapDataCache cache)
saveFile
- The directory to save BigChunk
in. Cannot be null.cache
- The MapDataCache
containing the data. Cannot be null.public boolean save(BigChunkLocation coord, BigChunk data)
coord
- The BigChunkLocation
of the data, cannot be null.data
- The BigChunk
to save, cannot be null.public boolean saveBlocking()
public void load(BigChunkLocation coord)
BigChunkLocation
as soon as possible.coord
- The BigChunkLocation
to load, cannot be null.public void update()
public boolean isSaving(ChunkLocation location)
public boolean isLoading(ChunkLocation location)
protected java.io.File getFileFor(BigChunkLocation coord)
BigChunkLocation
.coord
- The coordinate of the BigChunkLocation
, cannot be null.