@@ -209,7 +209,7 @@ class multithreaded_processor
209209 */
210210 void process_ways (idlist_t &&list)
211211 {
212- process_queue (" way" , std::move (list), do_ways );
212+ process_queue (" way" , std::move (list), & output_t ::pending_way );
213213 }
214214
215215 /* *
@@ -220,7 +220,7 @@ class multithreaded_processor
220220 */
221221 void process_relations (idlist_t &&list)
222222 {
223- process_queue (" relation" , std::move (list), do_rels );
223+ process_queue (" relation" , std::move (list), & output_t ::pending_relation );
224224 }
225225
226226 /* *
@@ -256,38 +256,20 @@ class multithreaded_processor
256256 return id;
257257 }
258258
259- /* *
260- * Runs in the worker threads: As long as there are any, get ids from
261- * the queue and let the outputs process the ways.
262- */
263- static void do_ways (output_vec_t const &outputs, idlist_t *queue,
264- std::mutex *mutex)
265- {
266- while (osmid_t const id = pop_id (queue, mutex)) {
267- for (auto const &output : outputs) {
268- if (output) {
269- output->pending_way (id);
270- }
271- }
272- }
273- for (auto const &output : outputs) {
274- if (output) {
275- output->sync ();
276- }
277- }
278- }
259+ // Pointer to a member function of output_t taking an osm_id
260+ using output_member_fn_ptr = void (output_t ::*)(osmid_t );
279261
280262 /* *
281263 * Runs in the worker threads: As long as there are any, get ids from
282- * the queue and let the outputs process the relations .
264+ * the queue and let the outputs process it by calling "func" .
283265 */
284- static void do_rels (output_vec_t const &outputs, idlist_t *queue,
285- std::mutex *mutex)
266+ static void run (output_vec_t const &outputs, idlist_t *queue,
267+ std::mutex *mutex, output_member_fn_ptr func )
286268 {
287269 while (osmid_t const id = pop_id (queue, mutex)) {
288270 for (auto const &output : outputs) {
289271 if (output) {
290- output-> pending_relation (id);
272+ ( output. get ()->*func) (id);
291273 }
292274 }
293275 }
@@ -313,8 +295,8 @@ class multithreaded_processor
313295 } while (queue_size > 0 );
314296 }
315297
316- template < typename FUNCTION>
317- void process_queue ( char const *type, idlist_t list, FUNCTION && function)
298+ void process_queue ( char const *type, idlist_t list,
299+ output_member_fn_ptr function)
318300 {
319301 auto const ids_queued = list.size ();
320302
@@ -326,12 +308,12 @@ class multithreaded_processor
326308 std::vector<std::future<void >> workers;
327309
328310 for (auto const &clone : m_clones) {
329- workers.push_back (std::async (
330- std::launch::async, std::forward<FUNCTION>(function) ,
331- std::cref (clone), &list, &m_mutex ));
311+ workers.push_back (std::async (std::launch::async, run,
312+ std::cref (clone), &list, &m_mutex ,
313+ function ));
332314 }
333- workers.push_back (std::async (std::launch::async, print_stats,
334- &list, &m_mutex));
315+ workers.push_back (
316+ std::async (std::launch::async, print_stats, &list, &m_mutex));
335317
336318 for (auto &worker : workers) {
337319 try {
0 commit comments