Skip to content

Commit e07ae60

Browse files
committed
Remove m_queue member variable in multithreaded_processor
1 parent c41eb92 commit e07ae60

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/osmdata.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,7 @@ class multithreaded_processor
209209
*/
210210
void process_ways(idlist_t &&list)
211211
{
212-
m_queue = std::move(list);
213-
process_queue("way", do_ways);
212+
process_queue("way", std::move(list), do_ways);
214213
}
215214

216215
/**
@@ -221,8 +220,7 @@ class multithreaded_processor
221220
*/
222221
void process_relations(idlist_t &&list)
223222
{
224-
m_queue = std::move(list);
225-
process_queue("relation", do_rels);
223+
process_queue("relation", std::move(list), do_rels);
226224

227225
// Collect expiry tree information from all clones and merge it back
228226
// into the original outputs.
@@ -301,9 +299,9 @@ class multithreaded_processor
301299
}
302300

303301
template <typename FUNCTION>
304-
void process_queue(char const *type, FUNCTION &&function)
302+
void process_queue(char const *type, idlist_t list, FUNCTION &&function)
305303
{
306-
auto const ids_queued = m_queue.size();
304+
auto const ids_queued = list.size();
307305

308306
fmt::print(stderr, "\nGoing over pending {}s...\n", type);
309307
fmt::print(stderr, "\t{} {}s are pending\n", ids_queued, type);
@@ -315,18 +313,18 @@ class multithreaded_processor
315313
for (auto const &clone : m_clones) {
316314
workers.push_back(std::async(
317315
std::launch::async, std::forward<FUNCTION>(function),
318-
std::cref(clone), &m_queue, &m_mutex));
316+
std::cref(clone), &list, &m_mutex));
319317
}
320318
workers.push_back(std::async(std::launch::async, print_stats,
321-
&m_queue, &m_mutex));
319+
&list, &m_mutex));
322320

323321
for (auto &worker : workers) {
324322
try {
325323
worker.get();
326324
} catch (...) {
327325
// Drain the queue, so that the other workers finish early.
328326
m_mutex.lock();
329-
m_queue.clear();
327+
list.clear();
330328
m_mutex.unlock();
331329
throw;
332330
}
@@ -359,9 +357,6 @@ class multithreaded_processor
359357
/// All outputs.
360358
output_vec_t m_outputs;
361359

362-
/// The queue with ids that the worker threads work on.
363-
idlist_t m_queue;
364-
365360
/// Mutex to make sure worker threads coordinate access to queue.
366361
std::mutex m_mutex;
367362
};

0 commit comments

Comments
 (0)