Skip to content

Commit 0beb10f

Browse files
authored
Merge pull request #1180 from joto/output-commit-in-thread
Move commits of outputs into threads
2 parents c8accd1 + 71b6ddf commit 0beb10f

14 files changed

+26
-25
lines changed

src/flex-table.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class table_connection_t
226226

227227
pg_result_t get_geom_by_id(osmium::item_type type, osmid_t id) const;
228228

229-
void commit() { m_copy_mgr.sync(); }
229+
void sync() { m_copy_mgr.sync(); }
230230

231231
void new_line() { m_copy_mgr.new_line(m_target); }
232232

src/osmdata.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,11 @@ class multithreaded_processor
270270
}
271271
}
272272
}
273+
for (auto const &output : outputs) {
274+
if (output) {
275+
output->sync();
276+
}
277+
}
273278
}
274279

275280
/**
@@ -286,6 +291,11 @@ class multithreaded_processor
286291
}
287292
}
288293
}
294+
for (auto const &output : outputs) {
295+
if (output) {
296+
output->sync();
297+
}
298+
}
289299
}
290300

291301
/// Runs in a worker thread: Update progress display once per second.
@@ -335,14 +345,6 @@ class multithreaded_processor
335345
}
336346
}
337347

338-
for (auto const &clone : m_clones) {
339-
for (auto const &clone_output : clone) {
340-
if (clone_output) {
341-
clone_output->commit();
342-
}
343-
}
344-
}
345-
346348
timer.stop();
347349

348350
fmt::print(stderr, "\rFinished processing {} {}s in {} s\n\n",
@@ -376,8 +378,7 @@ void osmdata_t::stop() const
376378
*/
377379
m_mid->commit();
378380
for (auto &out : m_outs) {
379-
//TODO: each of the outs can be in parallel
380-
out->commit();
381+
out->sync();
381382
}
382383

383384
// should be the same for all outputs

src/output-flex.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,10 +1053,10 @@ void output_flex_t::pending_relation(osmid_t id)
10531053
m_rels_buffer.clear();
10541054
}
10551055

1056-
void output_flex_t::commit()
1056+
void output_flex_t::sync()
10571057
{
10581058
for (auto &table : m_table_connections) {
1059-
table.commit();
1059+
table.sync();
10601060
}
10611061
}
10621062

src/output-flex.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class output_flex_t : public output_t
5757

5858
void start() override;
5959
void stop(osmium::thread::Pool *pool) override;
60-
void commit() override;
60+
void sync() override;
6161

6262
void stage2_proc() override;
6363

src/output-gazetteer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void output_gazetteer_t::start()
6767
}
6868
}
6969

70-
void output_gazetteer_t::commit() { m_copy.sync(); }
70+
void output_gazetteer_t::sync() { m_copy.sync(); }
7171

7272
void output_gazetteer_t::node_add(osmium::Node const &node)
7373
{

src/output-gazetteer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class output_gazetteer_t : public output_t
4343

4444
void start() override;
4545
void stop(osmium::thread::Pool *) noexcept override {}
46-
void commit() override;
46+
void sync() override;
4747

4848
bool need_forward_dependencies() const noexcept override { return false; }
4949

src/output-multi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void output_multi_t::stop(osmium::thread::Pool *pool)
9797
}
9898
}
9999

100-
void output_multi_t::commit() { m_table->commit(); }
100+
void output_multi_t::sync() { m_table->sync(); }
101101

102102
void output_multi_t::node_add(osmium::Node const &node)
103103
{

src/output-multi.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class output_multi_t : public output_t
4444

4545
void start() override;
4646
void stop(osmium::thread::Pool *pool) override;
47-
void commit() override;
47+
void sync() override;
4848

4949
void pending_way(osmid_t id) override;
5050
void pending_relation(osmid_t id) override;

src/output-null.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class output_null_t : public output_t
1919

2020
void start() override {}
2121
void stop(osmium::thread::Pool * /*pool*/) override {}
22-
void commit() override {}
22+
void sync() override {}
2323
void cleanup() {}
2424

2525
bool need_forward_dependencies() const noexcept override { return false; }

src/output-pgsql.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ void output_pgsql_t::pending_relation(osmid_t id)
102102
}
103103
}
104104

105-
void output_pgsql_t::commit()
105+
void output_pgsql_t::sync()
106106
{
107107
for (auto const &t : m_tables) {
108-
t->commit();
108+
t->sync();
109109
}
110110
}
111111

0 commit comments

Comments
 (0)