Skip to content

Commit

Permalink
Re-use ifstream and OSMLuaProcessing (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
cldellow authored Nov 12, 2023
1 parent 9c7081b commit 8c059d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/read_pbf.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class PbfReader

PbfReader(OSMStore &osmStore);

using pbfreader_generate_output = std::function< std::unique_ptr<OsmLuaProcessing> () >;
using pbfreader_generate_stream = std::function< std::unique_ptr<std::istream> () >;
using pbfreader_generate_output = std::function< std::shared_ptr<OsmLuaProcessing> () >;
using pbfreader_generate_stream = std::function< std::shared_ptr<std::istream> () >;

int ReadPbfFile(std::unordered_set<std::string> const &nodeKeys, unsigned int threadNum,
pbfreader_generate_stream const &generate_stream,
Expand Down
6 changes: 4 additions & 2 deletions src/tilemaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,12 @@ int main(int argc, char* argv[]) {

int ret = pbfReader.ReadPbfFile(nodeKeys, threadNum,
[&]() {
return std::make_unique<ifstream>(inputFile, ios::in | ios::binary);
thread_local std::shared_ptr<ifstream> pbfStream(new ifstream(inputFile, ios::in | ios::binary));
return pbfStream;
},
[&]() {
return std::make_unique<OsmLuaProcessing>(osmStore, config, layers, luaFile, shpMemTiles, osmMemTiles, attributeStore);
thread_local std::shared_ptr<OsmLuaProcessing> osmLuaProcessing(new OsmLuaProcessing(osmStore, config, layers, luaFile, shpMemTiles, osmMemTiles, attributeStore));
return osmLuaProcessing;
});
if (ret != 0) return ret;
}
Expand Down

0 comments on commit 8c059d9

Please sign in to comment.