diff --git a/src/main.cpp b/src/main.cpp index f6b0d03..dba5f23 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,10 +18,11 @@ struct month_info { int main(int argc, char *argv[]) { unsigned int distance = 2'000; std::string fire_dir = "fires"; + unsigned int wc = 0; std::filesystem::path out_dir = "out"; auto do_sort = false; int c; - while ((c = getopt(argc, argv, "d:f:o:s")) != -1) { + while ((c = getopt(argc, argv, "d:f:j:o:s")) != -1) { switch (c) { case 'd': distance = atoi(optarg); @@ -29,6 +30,9 @@ int main(int argc, char *argv[]) { case 'f': fire_dir = optarg; break; + case 'j': + wc = atoi(optarg); + break; case 'o': out_dir = optarg; break; @@ -47,6 +51,15 @@ int main(int argc, char *argv[]) { } } + if (wc == 0) { + wc = std::thread::hardware_concurrency(); + if (wc == 0) { + wc = 1; + } else if (wc > 1) { + wc--; + } + } + char *res_loc; switch (argc - optind) { case 0: { @@ -166,12 +179,6 @@ int main(int argc, char *argv[]) { auto it = all_fires.begin(); unsigned int n_done = 0; std::mutex it_lock; - auto wc = std::thread::hardware_concurrency(); - if (wc == 0) { - wc = 1; - } else if (wc > 1) { - wc--; - } std::cout << "Starting " << wc << " worker threads..." << std::endl; for (unsigned int w = 1; w <= wc; w++) { workers.push_back(std::thread([&it, &n_done, &it_lock, &all_fires,