Scope the Tile worker thread to an Environment

We are also removing the code that is passing the Environment around
and instead, we get now the Environment in the TileData using
Environment::Get().

When processing the job, the work will be temporally registered to
the Environment as "TileWorker_0/0/0" which can be used for logging
in the future. At the end of the job, it gets unregistered
automatically from the Environment.
This commit is contained in:
Thiago Marcos P. Santos
2015-03-13 19:04:55 +02:00
committed by Konstantin Käfer
parent b5facd35bc
commit aa9adbb8f8
14 changed files with 43 additions and 48 deletions

View File

@@ -155,7 +155,7 @@ TileData::State Source::hasTile(const Tile::ID& id) {
return TileData::State::invalid;
}
TileData::State Source::addTile(Map &map, Environment &env, uv::worker &worker,
TileData::State Source::addTile(Map &map, uv::worker &worker,
util::ptr<Style> style, GlyphAtlas &glyphAtlas,
GlyphStore &glyphStore, SpriteAtlas &spriteAtlas,
util::ptr<Sprite> sprite, TexturePool &texturePool,
@@ -187,22 +187,18 @@ TileData::State Source::addTile(Map &map, Environment &env, uv::worker &worker,
if (!new_tile.data) {
// If we don't find working tile data, we're just going to load it.
if (info.type == SourceType::Vector) {
new_tile.data = std::make_shared<VectorTileData>(normalized_id, map.getMaxZoom(), style,
glyphAtlas, glyphStore,
spriteAtlas, sprite,
info, env);
new_tile.data =
std::make_shared<VectorTileData>(normalized_id, map.getMaxZoom(), style, glyphAtlas,
glyphStore, spriteAtlas, sprite, info);
new_tile.data->request(worker, map.getState().getPixelRatio(), callback);
} else if (info.type == SourceType::Raster) {
new_tile.data = std::make_shared<RasterTileData>(normalized_id, texturePool, info, env);
new_tile.data = std::make_shared<RasterTileData>(normalized_id, texturePool, info);
new_tile.data->request(worker, map.getState().getPixelRatio(), callback);
} else if (info.type == SourceType::Annotations) {
AnnotationManager& annotationManager = map.getAnnotationManager();
new_tile.data = std::make_shared<LiveTileData>(normalized_id,
annotationManager,
map.getMaxZoom(), style,
glyphAtlas, glyphStore,
spriteAtlas, sprite,
info, env);
new_tile.data = std::make_shared<LiveTileData>(normalized_id, annotationManager,
map.getMaxZoom(), style, glyphAtlas,
glyphStore, spriteAtlas, sprite, info);
new_tile.data->reparse(worker, callback);
} else {
throw std::runtime_error("source type not implemented");
@@ -293,7 +289,6 @@ bool Source::findLoadedParent(const Tile::ID& id, int32_t minCoveringZoom, std::
}
void Source::update(Map &map,
Environment &env,
uv::worker &worker,
util::ptr<Style> style,
GlyphAtlas &glyphAtlas,
@@ -322,7 +317,7 @@ void Source::update(Map &map,
// Add existing child/parent tiles if the actual tile is not yet loaded
for (const Tile::ID& id : required) {
const TileData::State state = addTile(map, env, worker, style, glyphAtlas, glyphStore,
const TileData::State state = addTile(map, worker, style, glyphAtlas, glyphStore,
spriteAtlas, sprite, texturePool, id, callback);
if (state != TileData::State::parsed) {