Skip to content

Commit

Permalink
Speed up multithreading by avoiding superfluous waits when pruning
Browse files Browse the repository at this point in the history
  • Loading branch information
vaeth committed Feb 27, 2017
1 parent 768be40 commit eacfb87
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# ChangeLog for chessproblem

*chessproblem-2.4
- Speed up multithreading by avoiding superfluous waits when pruning

*chessproblem-2.3
- Rename PushGuard->push_guard and PushGuardDisarmable->unique_push
in analogy to std::lock_guard and std::unique_lock.
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Martin V\"ath <martin@mvath.de>

dnl keep version in same line as AC_INIT for possible usage in scripts
AC_INIT([chessproblem], [2.3],
AC_INIT([chessproblem], [2.4],
[https://github.com/vaeth/chessproblem/issues/],
[chessproblem],
[https://github.com/vaeth/chessproblem/])
Expand Down
14 changes: 10 additions & 4 deletions src/chessproblem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -532,12 +532,18 @@ void ChessProblem::SolverThread(chessproblem::Communicate *communicate,
if (SingleThreadedMode()) { // Only a shortcut
return;
}
for (auto& t : threads) {
t.join();
}
if (subthread) { // We are at the end of a subthread
delete field;
DecreaseThreads();
DecreaseThreads(); // We might be not ready, but we will only wait
}
if (communicate->GotSignal()) {
for (auto& t : threads) { // No need to wait for exiting threads
t.detach();
}
} else {
for (auto& t : threads) {
t.join();
}
}
}
#endif // NO_CHESSPROBLEM_THREADS

0 comments on commit eacfb87

Please sign in to comment.