@@ -186,8 +186,7 @@ namespace {
186186// since the fetching from middle should be faster than the processing in each backend.
187187
188188struct pending_threaded_processor : public middle_t ::pending_processor {
189- typedef std::vector<std::shared_ptr<output_t >> output_vec_t ;
190- typedef std::pair<std::shared_ptr<middle_query_t >, output_vec_t > clone_t ;
189+ using output_vec_t = std::vector<std::shared_ptr<output_t >>;
191190
192191 static void do_jobs (output_vec_t const & outputs, pending_queue_t & queue, size_t & ids_done, std::mutex& mutex, int append, bool ways) {
193192 while (true ) {
@@ -253,11 +252,11 @@ struct pending_threaded_processor : public middle_t::pending_processor {
253252 // clone the outs
254253 output_vec_t out_clones;
255254 for (const auto & out: outs) {
256- out_clones.push_back (out->clone (mid_clone. get () ));
255+ out_clones.push_back (out->clone (mid_clone));
257256 }
258257
259258 // keep the clones for a specific thread to use
260- clones.push_back (clone_t (mid_clone, out_clones) );
259+ clones.push_back (out_clones);
261260 }
262261 }
263262
@@ -282,11 +281,10 @@ struct pending_threaded_processor : public middle_t::pending_processor {
282281
283282 // make the threads and start them
284283 std::vector<std::future<void >> workers;
285- for (size_t i = 0 ; i < clones.size (); ++i) {
286- workers.push_back (std::async (std::launch::async,
287- do_jobs, std::cref (clones[i].second ),
288- std::ref (queue), std::ref (ids_done),
289- std::ref (mutex), append, true ));
284+ for (auto const &clone : clones) {
285+ workers.push_back (std::async (
286+ std::launch::async, do_jobs, std::cref (clone), std::ref (queue),
287+ std::ref (ids_done), std::ref (mutex), append, true ));
290288 }
291289 workers.push_back (std::async (std::launch::async, print_stats,
292290 std::ref (queue), std::ref (mutex)));
@@ -315,10 +313,12 @@ struct pending_threaded_processor : public middle_t::pending_processor {
315313
316314 // collect all the new rels that became pending from each
317315 // output in each thread back to their respective main outputs
318- for (const auto & clone: clones) {
316+ for (auto const & clone : clones) {
319317 // for each clone/original output
320- for (output_vec_t ::const_iterator original_output = outs.begin (), clone_output = clone.second .begin ();
321- original_output != outs.end () && clone_output != clone.second .end (); ++original_output, ++clone_output) {
318+ for (output_vec_t ::const_iterator original_output = outs.begin (),
319+ clone_output = clone.begin ();
320+ original_output != outs.end () && clone_output != clone.end ();
321+ ++original_output, ++clone_output) {
322322 // done copying ways for now
323323 clone_output->get ()->commit ();
324324 // merge the pending from this threads copy of output back
@@ -344,11 +344,10 @@ struct pending_threaded_processor : public middle_t::pending_processor {
344344
345345 // make the threads and start them
346346 std::vector<std::future<void >> workers;
347- for (size_t i = 0 ; i < clones.size (); ++i) {
348- workers.push_back (std::async (std::launch::async,
349- do_jobs, std::cref (clones[i].second ),
350- std::ref (queue), std::ref (ids_done),
351- std::ref (mutex), append, false ));
347+ for (auto const &clone : clones) {
348+ workers.push_back (std::async (
349+ std::launch::async, do_jobs, std::cref (clone), std::ref (queue),
350+ std::ref (ids_done), std::ref (mutex), append, false ));
352351 }
353352 workers.push_back (std::async (std::launch::async, print_stats,
354353 std::ref (queue), std::ref (mutex)));
@@ -376,10 +375,12 @@ struct pending_threaded_processor : public middle_t::pending_processor {
376375 ids_done = 0 ;
377376
378377 // collect all expiry tree informations together into one
379- for (const auto & clone: clones) {
378+ for (auto const & clone : clones) {
380379 // for each clone/original output
381- for (output_vec_t ::const_iterator original_output = outs.begin (), clone_output = clone.second .begin ();
382- original_output != outs.end () && clone_output != clone.second .end (); ++original_output, ++clone_output) {
380+ for (output_vec_t ::const_iterator original_output = outs.begin (),
381+ clone_output = clone.begin ();
382+ original_output != outs.end () && clone_output != clone.end ();
383+ ++original_output, ++clone_output) {
383384 // done copying rels for now
384385 clone_output->get ()->commit ();
385386 // merge the expire tree from this threads copy of output back
@@ -389,8 +390,8 @@ struct pending_threaded_processor : public middle_t::pending_processor {
389390 }
390391
391392private:
392- // middle and output copies
393- std::vector<clone_t > clones;
393+ // output copies, one vector per thread
394+ std::vector<output_vec_t > clones;
394395 output_vec_t outs; // would like to move ownership of outs to osmdata_t and middle passed to output_t instead of owned by it
395396 // how many jobs do we have in the queue to start with
396397 size_t ids_queued;
0 commit comments