Skip to content

Commit 172adcb

Browse files
committed
Make semaphore count configurable and default to 32.
1 parent b20bff3 commit 172adcb

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

src/structures/typedefs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ constexpr unsigned MAX_EXPLORATION_LEVEL = 5;
8282

8383
constexpr unsigned DEFAULT_EXPLORATION_LEVEL = 5;
8484
constexpr unsigned DEFAULT_THREADS_NUMBER = 4;
85+
constexpr unsigned MAX_ROUTING_THREADS = 32;
8586

8687
constexpr auto DEFAULT_MAX_TASKS = std::numeric_limits<size_t>::max();
8788
constexpr auto DEFAULT_MAX_TRAVEL_TIME = std::numeric_limits<Duration>::max();

src/structures/vroom/input/input.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,8 @@ Solution Input::solve(const unsigned nb_searches,
12451245
threads.reserve(sol.routes.size());
12461246
std::exception_ptr ep = nullptr;
12471247
std::mutex ep_m;
1248-
std::counting_semaphore<128> semaphore(nb_thread);
1248+
std::counting_semaphore<MAX_ROUTING_THREADS> semaphore(
1249+
std::min(MAX_ROUTING_THREADS, nb_thread));
12491250

12501251
auto run_routing = [this, &semaphore, &sol, &ep, &ep_m](std::size_t i) {
12511252
semaphore.acquire();

0 commit comments

Comments
 (0)