@@ -318,6 +318,24 @@ static osmium::Box parse_bbox(char const *bbox)
318318 return osmium::Box{minx, miny, maxx, maxy};
319319}
320320
321+ static unsigned int number_of_threads (char const *arg)
322+ {
323+ int num = atoi (arg);
324+ if (num < 1 ) {
325+ log_warn (" --number-processes must be at least 1. Using 1." );
326+ num = 1 ;
327+ } else if (num > 32 ) {
328+ // The threads will open up database connections which will
329+ // run out at some point. It depends on the number of tables
330+ // how many connections there are. The number 32 is way beyond
331+ // anything that will make sense here.
332+ log_warn (" --number-processes too large. Set to 32." );
333+ num = 32 ;
334+ }
335+
336+ return static_cast <unsigned int >(num);
337+ }
338+
321339options_t ::options_t (int argc, char *argv[]) : options_t ()
322340{
323341 // If there are no command line arguments at all, show help.
@@ -503,18 +521,7 @@ options_t::options_t(int argc, char *argv[]) : options_t()
503521 log_warn (" Deprecated option --cache-strategy ignored" );
504522 break ;
505523 case 205 :
506- num_procs = atoi (optarg);
507- if (num_procs < 1 ) {
508- log_warn (" --number-processes must be at least 1. Using 1." );
509- num_procs = 1 ;
510- } else if (num_procs > 32 ) {
511- // The threads will open up database connections which will
512- // run out at some point. It depends on the number of tables
513- // how many connections there are. The number 32 is way beyond
514- // anything that will make sense here.
515- log_warn (" --number-processes too large. Set to 32." );
516- num_procs = 32 ;
517- }
524+ num_procs = number_of_threads (optarg);
518525 break ;
519526 case 206 :
520527 droptemp = true ;
0 commit comments