Merge branch 'tm_fix_jobs_deadlock'

This commit is contained in:
tamasmeszaros 2023-10-09 15:08:23 +02:00
commit f41b810c1a

View File

@ -57,11 +57,10 @@ TEMPLATE_LIST_TEST_CASE("State should not be idle while running a job", "[Jobs]"
}).wait(); }).wait();
}); });
worker.wait_for_idle(); // make sure that the job starts BEFORE the worker.wait_for_idle() is called
std::this_thread::sleep_for(std::chrono::milliseconds(100));
// To avoid stalling the job, in case the wait_for_idle is called before worker.wait_for_idle();
// the job goes into blocking wait
worker.process_events();
REQUIRE(worker.is_idle()); REQUIRE(worker.is_idle());
} }
@ -79,13 +78,12 @@ TEMPLATE_LIST_TEST_CASE("Status messages should be received by the main thread d
}); });
worker.wait_for_idle(); worker.wait_for_idle();
worker.process_events();
REQUIRE(pri->pr == 100); REQUIRE(pri->pr == 100);
REQUIRE(pri->statustxt == "Running"); REQUIRE(pri->statustxt == "Running");
} }
TEMPLATE_LIST_TEST_CASE("Cancellation should be recognized by the worker", "[Jobs]", TestClasses) { TEMPLATE_LIST_TEST_CASE("Cancellation should be recognized be the worker", "[Jobs]", TestClasses) {
using namespace Slic3r; using namespace Slic3r;
using namespace Slic3r::GUI; using namespace Slic3r::GUI;
@ -110,7 +108,6 @@ TEMPLATE_LIST_TEST_CASE("Cancellation should be recognized by the worker", "[Job
worker.cancel(); worker.cancel();
worker.wait_for_current_job(); worker.wait_for_current_job();
worker.process_events();
REQUIRE(pri->pr != 100); REQUIRE(pri->pr != 100);
} }
@ -148,7 +145,6 @@ TEMPLATE_LIST_TEST_CASE("cancel_all should remove all pending jobs", "[Jobs]", T
// during the first job's execution. // during the first job's execution.
std::this_thread::sleep_for(std::chrono::milliseconds(500)); std::this_thread::sleep_for(std::chrono::milliseconds(500));
worker.cancel_all(); worker.cancel_all();
worker.process_events();
REQUIRE(jobres[0] == true); REQUIRE(jobres[0] == true);
REQUIRE(jobres[1] == false); REQUIRE(jobres[1] == false);
@ -177,7 +173,5 @@ TEMPLATE_LIST_TEST_CASE("Exception should be properly forwarded to finalize()",
}); });
worker.wait_for_idle(); worker.wait_for_idle();
worker.process_events();
REQUIRE(worker.is_idle()); REQUIRE(worker.is_idle());
} }