1#include <test/jtx/Env.h>
3#include <xrpl/beast/unit_test.h>
4#include <xrpl/core/JobQueue.h>
18 JobQueue& jQueue = env.app().getJobQueue();
22 BEAST_EXPECT(jQueue.
addJob(
jtCLIENT,
"JobAddTest1", [&jobRan]() { jobRan = true; }) ==
true);
25 while (jobRan ==
false)
32 using namespace std::chrono_literals;
39 BEAST_EXPECT(jQueue.
addJob(
jtCLIENT,
"JobAddTest2", [&unprotected]() { unprotected = false; }) ==
false);
48 JobQueue& jQueue = env.app().getJobQueue();
54 while (++yieldCount < 4)
57 BEAST_EXPECT(coro !=
nullptr);
60 while (yieldCount == 0)
65 while (coro->runnable())
67 BEAST_EXPECT(coro->post());
68 while (old == yieldCount)
72 BEAST_EXPECT(++old == yieldCount);
74 BEAST_EXPECT(yieldCount == 4);
81 while (++yieldCount < 4)
97 while (coro->runnable())
100 BEAST_EXPECT(++old == yieldCount);
102 BEAST_EXPECT(yieldCount == 4);
108 using namespace std::chrono_literals;
119 BEAST_EXPECT(coro ==
nullptr);
A pool of threads to perform work.
std::shared_ptr< Coro > postCoro(JobType t, std::string const &name, F &&f)
Creates a coroutine and adds a job to the queue which will run it.
bool addJob(JobType type, std::string const &name, JobHandler &&jobHandler)
Adds a job to the JobQueue.
void run() override
Runs the suite.
A transaction testing environment.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.