make TileManager.jobQueue private
- use hasTileJobs(), getTileJob(), jobCompleted() instead
This commit is contained in:
parent
e35f39c9f4
commit
18d0bfc3c5
@ -57,7 +57,7 @@ public abstract class TileLoader {
|
||||
mPausing = false;
|
||||
// FIXME
|
||||
mWorking = false;
|
||||
if (!mTileManager.jobQueue.isEmpty())
|
||||
if (mTileManager.hasTileJobs())
|
||||
go();
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ public abstract class TileLoader {
|
||||
return;
|
||||
}
|
||||
|
||||
MapTile tile = mTileManager.jobQueue.poll();
|
||||
MapTile tile = mTileManager.getTileJob();
|
||||
|
||||
if (tile == null)
|
||||
return;
|
||||
@ -96,16 +96,14 @@ public abstract class TileLoader {
|
||||
}
|
||||
|
||||
public void jobCompleted(MapTile tile, boolean success) {
|
||||
//if (success) {
|
||||
if (!isInterrupted) {
|
||||
// pass tile to main thread
|
||||
mTileManager.passTile(tile, success);
|
||||
}
|
||||
//}
|
||||
if (isInterrupted)
|
||||
success = false;
|
||||
|
||||
mTileManager.jobCompleted(tile, success);
|
||||
|
||||
mWorking = false;
|
||||
|
||||
if (!mPausing && !mTileManager.jobQueue.isEmpty()) {
|
||||
if (!mPausing && mTileManager.hasTileJobs()) {
|
||||
|
||||
Gdx.app.postRunnable(new Runnable() {
|
||||
|
||||
|
@ -40,7 +40,7 @@ public abstract class TileLoader extends PausableThread {
|
||||
|
||||
@Override
|
||||
protected void doWork() {
|
||||
MapTile tile = mTileManager.jobQueue.poll();
|
||||
MapTile tile = mTileManager.getTileJob();
|
||||
|
||||
if (tile == null)
|
||||
return;
|
||||
@ -54,9 +54,10 @@ public abstract class TileLoader extends PausableThread {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isInterrupted()) {
|
||||
mTileManager.passTile(tile, success);
|
||||
}
|
||||
if (isInterrupted())
|
||||
success = false;
|
||||
|
||||
mTileManager.jobCompleted(tile, success);
|
||||
}
|
||||
|
||||
public void jobCompleted(MapTile tile, boolean success) {
|
||||
@ -75,6 +76,6 @@ public abstract class TileLoader extends PausableThread {
|
||||
|
||||
@Override
|
||||
protected boolean hasWork() {
|
||||
return !mTileManager.jobQueue.isEmpty();
|
||||
return mTileManager.hasTileJobs();
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public class TileManager {
|
||||
/* package */TileSet mNewTiles;
|
||||
|
||||
// job queue filled in TileManager and polled by TileLoaders
|
||||
final JobQueue jobQueue;
|
||||
private final JobQueue jobQueue;
|
||||
|
||||
private final QuadTreeIndex<MapTile> mIndex = new QuadTreeIndex<MapTile>() {
|
||||
|
||||
@ -294,6 +294,14 @@ public class TileManager {
|
||||
jobQueue.clear();
|
||||
}
|
||||
|
||||
public boolean hasTileJobs() {
|
||||
return !jobQueue.isEmpty();
|
||||
}
|
||||
|
||||
public MapTile getTileJob() {
|
||||
return jobQueue.poll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrive a TileSet of current tiles. Tiles remain locked in cache until
|
||||
* the set is unlocked by either passing it again to this function or to
|
||||
@ -537,7 +545,7 @@ public class TileManager {
|
||||
* Tile ready for upload in TileRenderLayer
|
||||
* @return caller does not care
|
||||
*/
|
||||
public void passTile(MapTile tile, boolean success) {
|
||||
public void jobCompleted(MapTile tile, boolean success) {
|
||||
|
||||
if (!success) {
|
||||
tile.clear();
|
||||
@ -547,7 +555,7 @@ public class TileManager {
|
||||
tile.state = STATE_NEW_DATA;
|
||||
|
||||
// is volatile
|
||||
mTilesForUpload++;
|
||||
mTilesForUpload += 1;
|
||||
|
||||
// locked means the tile is visible or referenced by
|
||||
// a tile that might be visible.
|
||||
|
Loading…
x
Reference in New Issue
Block a user