Skip to content

Commit 615addf

Browse files
committed
Remove copy_thread parameter from output constructors
The output derived classes can create the copy_thread themselves. They just need the options which they have anyway.
1 parent c706900 commit 615addf

6 files changed

Lines changed: 23 additions & 24 deletions

File tree

src/output-flex.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,11 +1997,10 @@ output_flex_t::clone(std::shared_ptr<middle_query_t> const &mid,
19971997
return std::make_shared<output_flex_t>(this, mid, copy_thread);
19981998
}
19991999

2000-
output_flex_t::output_flex_t(
2001-
std::shared_ptr<middle_query_t> const &mid,
2002-
std::shared_ptr<thread_pool_t> thread_pool, options_t const &o,
2003-
std::shared_ptr<db_copy_thread_t> const &copy_thread)
2004-
: output_t(mid, std::move(thread_pool), o), m_copy_thread(copy_thread),
2000+
output_flex_t::output_flex_t(std::shared_ptr<middle_query_t> const &mid,
2001+
std::shared_ptr<thread_pool_t> thread_pool,
2002+
options_t const &o)
2003+
: output_t(mid, std::move(thread_pool), o),
20052004
m_expire(o.expire_tiles_zoom, o.expire_tiles_max_bbox, o.projection)
20062005
{
20072006
init_lua(get_options()->style);

src/output-flex.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,9 @@ class output_flex_t : public output_t
9999
{
100100
public:
101101
/// Constructor for new objects
102-
output_flex_t(
103-
std::shared_ptr<middle_query_t> const &mid,
104-
std::shared_ptr<thread_pool_t> thread_pool, options_t const &options,
105-
std::shared_ptr<db_copy_thread_t> const &copy_thread);
102+
output_flex_t(std::shared_ptr<middle_query_t> const &mid,
103+
std::shared_ptr<thread_pool_t> thread_pool,
104+
options_t const &options);
106105

107106
/// Constructor for cloned objects
108107
output_flex_t(output_flex_t const *other,
@@ -286,7 +285,8 @@ class output_flex_t : public output_t
286285
// accessed while protected using the lua_mutex.
287286
std::shared_ptr<idset_t> m_stage2_way_ids = std::make_shared<idset_t>();
288287

289-
std::shared_ptr<db_copy_thread_t> m_copy_thread;
288+
std::shared_ptr<db_copy_thread_t> m_copy_thread =
289+
std::make_shared<db_copy_thread_t>(get_options()->conninfo);
290290

291291
// This is shared between all clones of the output and must only be
292292
// accessed while protected using the lua_mutex.

src/output-gazetteer.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ class output_gazetteer_t : public output_t
3232
/// Constructor for new objects
3333
output_gazetteer_t(std::shared_ptr<middle_query_t> const &mid,
3434
std::shared_ptr<thread_pool_t> thread_pool,
35-
options_t const &options,
36-
std::shared_ptr<db_copy_thread_t> const &copy_thread)
37-
: output_t(mid, std::move(thread_pool), options), m_copy(copy_thread),
35+
options_t const &options)
36+
: output_t(mid, std::move(thread_pool), options),
3837
m_proj(options.projection)
3938
{
4039
m_style.load_style(options.style);
@@ -96,12 +95,14 @@ class output_gazetteer_t : public output_t
9695
bool process_way(osmium::Way *way);
9796
bool process_relation(osmium::Relation const &rel);
9897

99-
gazetteer_copy_mgr_t m_copy;
98+
gazetteer_copy_mgr_t m_copy{
99+
std::make_shared<db_copy_thread_t>(get_options()->conninfo)};
100+
100101
gazetteer_style_t m_style;
101102

102103
std::shared_ptr<reprojection> m_proj;
103104
osmium::memory::Buffer m_osmium_buffer{
104105
PLACE_BUFFER_SIZE, osmium::memory::Buffer::auto_grow::yes};
105-
};
106+
};
106107

107108
#endif // OSM2PGSQL_OUTPUT_GAZETTEER_HPP

src/output-pgsql.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,7 @@ std::shared_ptr<output_t> output_pgsql_t::clone(
420420

421421
output_pgsql_t::output_pgsql_t(
422422
std::shared_ptr<middle_query_t> const &mid,
423-
std::shared_ptr<thread_pool_t> thread_pool, options_t const &o,
424-
std::shared_ptr<db_copy_thread_t> const &copy_thread)
423+
std::shared_ptr<thread_pool_t> thread_pool, options_t const &o)
425424
: output_t(mid, std::move(thread_pool), o), m_proj(o.projection),
426425
m_expire(o.expire_tiles_zoom, o.expire_tiles_max_bbox, o.projection),
427426
m_buffer(32768, osmium::memory::Buffer::auto_grow::yes),
@@ -436,6 +435,9 @@ output_pgsql_t::output_pgsql_t(
436435

437436
m_tagtransform = tagtransform_t::make_tagtransform(get_options(), exlist);
438437

438+
auto copy_thread =
439+
std::make_shared<db_copy_thread_t>(get_options()->conninfo);
440+
439441
//for each table
440442
for (size_t i = 0; i < t_MAX; ++i) {
441443

src/output-pgsql.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ class output_pgsql_t : public output_t
4040
/// Constructor for new objects
4141
output_pgsql_t(std::shared_ptr<middle_query_t> const &mid,
4242
std::shared_ptr<thread_pool_t> thread_pool,
43-
options_t const &options,
44-
std::shared_ptr<db_copy_thread_t> const &copy_thread);
43+
options_t const &options);
4544

4645
/// Constructor for cloned objects
4746
output_pgsql_t(output_pgsql_t const *other,

src/output.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,21 @@ output_t::create_output(std::shared_ptr<middle_query_t> const &mid,
3030
std::shared_ptr<thread_pool_t> thread_pool,
3131
options_t const &options)
3232
{
33-
auto copy_thread = std::make_shared<db_copy_thread_t>(options.conninfo);
34-
3533
if (options.output_backend == "pgsql") {
3634
return std::make_shared<output_pgsql_t>(mid, std::move(thread_pool),
37-
options, copy_thread);
35+
options);
3836
}
3937

4038
#ifdef HAVE_LUA
4139
if (options.output_backend == "flex") {
4240
return std::make_shared<output_flex_t>(mid, std::move(thread_pool),
43-
options, copy_thread);
41+
options);
4442
}
4543
#endif
4644

4745
if (options.output_backend == "gazetteer") {
4846
return std::make_shared<output_gazetteer_t>(mid, std::move(thread_pool),
49-
options, copy_thread);
47+
options);
5048
}
5149

5250
if (options.output_backend == "null") {

0 commit comments

Comments
 (0)