Skip to content

Commit 7723b5d

Browse files
committed
Used std::thread instead of std::jthread which is not supported in MacOS
1 parent 0081217 commit 7723b5d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/api/MainSolver.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ class MainSolver::ThreadImpl {
4444
private:
4545
MainSolver & solver;
4646

47-
std::jthread timeLimitThread{};
47+
// not using std::jthread since MacOS does not support it
48+
std::thread timeLimitThread{};
4849

4950
std::mutex mtx{};
5051
std::condition_variable condVar{};
@@ -632,7 +633,7 @@ MainSolver::ThreadImpl::~ThreadImpl() {
632633
if (not anyRunning()) { return; }
633634

634635
requestEnd();
635-
// no need to wait in destructor
636+
waitToEnd();
636637
}
637638

638639
void MainSolver::ThreadImpl::setTimeLimit(std::chrono::milliseconds limit) {
@@ -641,12 +642,12 @@ void MainSolver::ThreadImpl::setTimeLimit(std::chrono::milliseconds limit) {
641642
waitToEnd();
642643
}
643644

644-
timeLimitThread = std::jthread([this, limit] {
645+
timeLimitThread = decltype(timeLimitThread){[this, limit] {
645646
std::unique_lock lock(mtx);
646647
// To ensure that we do not wait later than when the notification was sent
647648
if (endReq) { return; }
648649
if (condVar.wait_for(lock, limit) == std::cv_status::timeout) { solver.notifyStop(); }
649-
});
650+
}};
650651
}
651652

652653
bool MainSolver::ThreadImpl::anyRunning() const noexcept {

0 commit comments

Comments
 (0)