Skip to content

Commit 47abd1d

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 47abd1d

File tree

6 files changed

+21
-23
lines changed

6 files changed

+21
-23
lines changed

src/output-flex.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,11 +1997,11 @@ 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),
2004+
m_copy_thread(std::make_shared<db_copy_thread_t>(get_options()->conninfo)),
20052005
m_expire(o.expire_tiles_zoom, o.expire_tiles_max_bbox, o.projection)
20062006
{
20072007
init_lua(get_options()->style);

src/output-flex.hpp

Lines changed: 3 additions & 4 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,

src/output-gazetteer.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ 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),
37+
m_copy(std::make_shared<db_copy_thread_t>(get_options()->conninfo)),
3838
m_proj(options.projection)
3939
{
4040
m_style.load_style(options.style);

src/output-pgsql.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,9 @@ std::shared_ptr<output_t> output_pgsql_t::clone(
418418
return std::make_shared<output_pgsql_t>(this, mid, copy_thread);
419419
}
420420

421-
output_pgsql_t::output_pgsql_t(
422-
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)
421+
output_pgsql_t::output_pgsql_t(std::shared_ptr<middle_query_t> const &mid,
422+
std::shared_ptr<thread_pool_t> thread_pool,
423+
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)