mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Simplify the Job Queue:
This is a refactor aimed at cleaning up and simplifying the existing job queue. As of now, all jobs are cancelled at the same time and in the same way, so this commit removes the per-job cancellation token. If the need for such support is demonstrated, support can be re-added. * Revise documentation for ClosureCounter and Workers. * Simplify code, removing unnecessary function arguments and deduplicating expressions * Restructure job handlers to no longer need to pass a job's handle to the job.
This commit is contained in:
committed by
Nik Bougalis
parent
df02eb125f
commit
c2a08a1f26
@@ -127,7 +127,7 @@ public:
|
||||
BEAST_EXPECT(*lv == -1);
|
||||
|
||||
gate g;
|
||||
jq.addJob(jtCLIENT, "LocalValue-Test", [&](auto const& job) {
|
||||
jq.addJob(jtCLIENT, "LocalValue-Test", [&]() {
|
||||
this->BEAST_EXPECT(*lv == -1);
|
||||
*lv = -2;
|
||||
this->BEAST_EXPECT(*lv == -2);
|
||||
@@ -166,7 +166,7 @@ public:
|
||||
c->join();
|
||||
}
|
||||
|
||||
jq.addJob(jtCLIENT, "LocalValue-Test", [&](auto const& job) {
|
||||
jq.addJob(jtCLIENT, "LocalValue-Test", [&]() {
|
||||
this->BEAST_EXPECT(*lv == -2);
|
||||
g.signal();
|
||||
});
|
||||
|
||||
@@ -37,10 +37,9 @@ class JobQueue_test : public beast::unit_test::suite
|
||||
{
|
||||
// addJob() should run the Job (and return true).
|
||||
std::atomic<bool> jobRan{false};
|
||||
BEAST_EXPECT(
|
||||
jQueue.addJob(jtCLIENT, "JobAddTest1", [&jobRan](Job&) {
|
||||
jobRan = true;
|
||||
}) == true);
|
||||
BEAST_EXPECT(jQueue.addJob(jtCLIENT, "JobAddTest1", [&jobRan]() {
|
||||
jobRan = true;
|
||||
}) == true);
|
||||
|
||||
// Wait for the Job to run.
|
||||
while (jobRan == false)
|
||||
@@ -58,7 +57,7 @@ class JobQueue_test : public beast::unit_test::suite
|
||||
// Not recommended for the faint of heart...
|
||||
bool unprotected;
|
||||
BEAST_EXPECT(
|
||||
jQueue.addJob(jtCLIENT, "JobAddTest2", [&unprotected](Job&) {
|
||||
jQueue.addJob(jtCLIENT, "JobAddTest2", [&unprotected]() {
|
||||
unprotected = false;
|
||||
}) == false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user