[core] destruct WorkTask data before calling the callback

This commit is contained in:
Konstantin Käfer
2016-01-27 20:44:44 +01:00
parent b492e2408d
commit e2a3c02d1a
4 changed files with 8 additions and 6 deletions

View File

@@ -146,7 +146,7 @@ private:
private:
template <std::size_t... I>
void invoke(std::index_sequence<I...>) {
func(std::get<I>(std::forward<P>(params))...);
func(std::move(std::get<I>(std::forward<P>(params)))...);
}
std::recursive_mutex mutex;

View File

@@ -37,7 +37,7 @@ TileWorker::~TileWorker() {
}
TileParseResult TileWorker::parseAllLayers(std::vector<std::unique_ptr<StyleLayer>> layers_,
const GeometryTile& geometryTile,
std::unique_ptr<const GeometryTile> geometryTile,
PlacementConfig config) {
// We're doing a fresh parse of the tile, because the underlying data has changed.
pending.clear();
@@ -55,7 +55,7 @@ TileParseResult TileWorker::parseAllLayers(std::vector<std::unique_ptr<StyleLaye
const StyleLayer* layer = i->get();
if (parsed.find(layer->bucketName()) == parsed.end()) {
parsed.emplace(layer->bucketName());
parseLayer(layer, geometryTile);
parseLayer(layer, *geometryTile);
}
}

View File

@@ -50,7 +50,7 @@ public:
~TileWorker();
TileParseResult parseAllLayers(std::vector<std::unique_ptr<StyleLayer>>,
const GeometryTile&,
std::unique_ptr<const GeometryTile> geometryTile,
PlacementConfig);
TileParseResult parsePendingLayers(PlacementConfig);

View File

@@ -16,10 +16,12 @@ public:
Impl() = default;
void parseRasterTile(std::unique_ptr<RasterBucket> bucket,
const std::shared_ptr<const std::string> data,
std::shared_ptr<const std::string> data,
std::function<void(RasterTileParseResult)> callback) {
try {
bucket->setImage(decodeImage(*data));
// Destruct the shared pointer before calling the callback.
data.reset();
callback(RasterTileParseResult(std::move(bucket)));
} catch (...) {
callback(std::current_exception());
@@ -32,7 +34,7 @@ public:
PlacementConfig config,
std::function<void(TileParseResult)> callback) {
try {
callback(worker->parseAllLayers(std::move(layers), *tile, config));
callback(worker->parseAllLayers(std::move(layers), std::move(tile), config));
} catch (...) {
callback(std::current_exception());
}