From 8c059d9cf572da925b2664bbe26b7ad1526db2b5 Mon Sep 17 00:00:00 2001 From: Colin Dellow Date: Sun, 12 Nov 2023 12:58:25 -0500 Subject: [PATCH] Re-use ifstream and OSMLuaProcessing (#578) --- include/read_pbf.h | 4 ++-- src/tilemaker.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/read_pbf.h b/include/read_pbf.h index df42e275..89077a6e 100644 --- a/include/read_pbf.h +++ b/include/read_pbf.h @@ -26,8 +26,8 @@ class PbfReader PbfReader(OSMStore &osmStore); - using pbfreader_generate_output = std::function< std::unique_ptr () >; - using pbfreader_generate_stream = std::function< std::unique_ptr () >; + using pbfreader_generate_output = std::function< std::shared_ptr () >; + using pbfreader_generate_stream = std::function< std::shared_ptr () >; int ReadPbfFile(std::unordered_set const &nodeKeys, unsigned int threadNum, pbfreader_generate_stream const &generate_stream, diff --git a/src/tilemaker.cpp b/src/tilemaker.cpp index 4e515aee..ffa9fe25 100644 --- a/src/tilemaker.cpp +++ b/src/tilemaker.cpp @@ -336,10 +336,12 @@ int main(int argc, char* argv[]) { int ret = pbfReader.ReadPbfFile(nodeKeys, threadNum, [&]() { - return std::make_unique(inputFile, ios::in | ios::binary); + thread_local std::shared_ptr pbfStream(new ifstream(inputFile, ios::in | ios::binary)); + return pbfStream; }, [&]() { - return std::make_unique(osmStore, config, layers, luaFile, shpMemTiles, osmMemTiles, attributeStore); + thread_local std::shared_ptr osmLuaProcessing(new OsmLuaProcessing(osmStore, config, layers, luaFile, shpMemTiles, osmMemTiles, attributeStore)); + return osmLuaProcessing; }); if (ret != 0) return ret; }