File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,8 @@ class MainSolver::TimeLimitImpl {
4545private:
4646 MainSolver & solver;
4747
48- std::jthread thread{};
48+ // not using std::jthread since MacOS does not support it
49+ std::thread thread{};
4950
5051 // See https://en.cppreference.com/w/cpp/thread/condition_variable.html
5152 std::mutex mtx{};
@@ -638,7 +639,7 @@ MainSolver::TimeLimitImpl::~TimeLimitImpl() {
638639 if (not isRunning ()) { return ; }
639640
640641 requestEnd ();
641- // no need to wait in destructor (thanks to std::jthread)
642+ waitToEnd ();
642643}
643644
644645void MainSolver::TimeLimitImpl::setLimit (std::chrono::milliseconds limit) {
@@ -650,14 +651,14 @@ void MainSolver::TimeLimitImpl::setLimit(std::chrono::milliseconds limit) {
650651 waitToEnd ();
651652 }
652653
653- thread = std::jthread ( [this , limit] {
654+ thread = decltype (thread){ [this , limit] {
654655 std::unique_lock lock (mtx);
655656 // Abort if a further future end request has already been sent
656657 if (endReq) { return ; }
657658 // Releases the lock and suspends the thread, waiting on a notification or timeout
658659 // Notification must be sent *after* the wait, otherwise could be missed - hence checking `endReq` above
659660 if (condVar.wait_for (lock, limit) == std::cv_status::timeout) { solver.notifyStop (); }
660- }) ;
661+ }} ;
661662}
662663
663664void MainSolver::TimeLimitImpl::setLimitIfNotRunning (std::chrono::milliseconds limit) {
You can’t perform that action at this time.
0 commit comments