@Override public Tile getTile(int x, int y, int zoom) { TileGenerator tileGenerator = mPool.get(); byte[] tileData = tileGenerator.getTileImageData(x, y, zoom); mPool.restore(tileGenerator); return new Tile(mDimension, mDimension, tileData); }
public void restore(TileGenerator tileGenerator) { if (mPool.size() < mMaxSize && mPool.offer(tileGenerator)) { return; } // pool is too big or returning to pool failed, so just try to clean // up. tileGenerator.cleanUp(); }