Skip to content

Commit

Permalink
remove threading from CachedDynamicTileManager
Browse files Browse the repository at this point in the history
didn't committed that intentionally in the first place
  • Loading branch information
brnkhy committed Oct 4, 2016
1 parent 1080e1c commit ad6e7af
Showing 1 changed file with 5 additions and 35 deletions.
40 changes: 5 additions & 35 deletions Assets/MapzenGo/Models/CachedDynamicTileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,51 +29,21 @@ public override void Start()
base.Start();
}

public override void Update()
{
base.Update();

lock (_readyToProcess)
{
if (_readyToProcess.Any())
{

var tile = _readyToProcess.Dequeue();
foreach (var factory in Plugins)
{
factory.Create(tile);
}
}
}
}

protected override void LoadTile(Vector2d tileTms, Tile tile)
{
var url = string.Format(_mapzenUrl, _mapzenLayers, Zoom, tileTms.x, tileTms.y, _mapzenFormat, _key);
//this is temporary (hopefully), cant just keep adding stuff to filenames
var tilePath = Path.Combine(string.Format(CacheFolderPath, tile.Zoom), _mapzenLayers.Replace(',', '_') + "_" + tileTms.x + "_" + tileTms.y);
var tilePath = Path.Combine(CacheFolderPath, _mapzenLayers.Replace(',', '_') + "_" + tileTms.x + "_" + tileTms.y);
if (File.Exists(tilePath))
{
ThreadPool.QueueUserWorkItem((s) =>
using (var r = new StreamReader(tilePath, Encoding.Default))
{
using (var r = new StreamReader((string)s, Encoding.Default))
{
var mapData = r.ReadToEnd();
//ConstructTile(mapData, tile);
var json = new JSONObject(mapData);
if (!tile) // checks if tile still exists and haven't destroyed yet
return;
tile.Data = json;

lock (_readyToProcess)
_readyToProcess.Enqueue(tile);

}
}, tilePath);
var mapData = r.ReadToEnd();
ConstructTile(mapData, tile);
}
}
else
{
Debug.Log(url);
ObservableWWW.Get(url).Subscribe(
success =>
{
Expand Down

0 comments on commit ad6e7af

Please sign in to comment.