3#include <xrpld/core/JobQueue.h>
24 template <
class Rep,
class Period>
46 using namespace std::chrono_literals;
52 cfg->FORCE_MULTI_THREAD =
true;
59 jtCLIENT,
"Coroutine-Test", [&](
auto const& cr) {
74 using namespace std::chrono_literals;
80 cfg->FORCE_MULTI_THREAD =
true;
86 jtCLIENT,
"Coroutine-Test", [&](
auto const& c) {
97 using namespace std::chrono_literals;
100 testcase(
"thread specific storage");
105 static int const N = 4;
109 BEAST_EXPECT(*lv == -1);
112 jq.addJob(
jtCLIENT,
"LocalValue-Test", [&]() {
113 this->BEAST_EXPECT(*lv == -1);
115 this->BEAST_EXPECT(*lv == -2);
119 BEAST_EXPECT(*lv == -1);
121 for (
int i = 0; i < N; ++i)
123 jq.postCoro(
jtCLIENT,
"Coroutine-Test", [&,
id = i](
auto const& c) {
128 this->BEAST_EXPECT(*lv == -1);
130 this->BEAST_EXPECT(*lv ==
id);
134 this->BEAST_EXPECT(*lv ==
id);
139 for (
auto const& c : a)
145 for (
auto const& c : a)
151 jq.addJob(
jtCLIENT,
"LocalValue-Test", [&]() {
152 this->BEAST_EXPECT(*lv == -2);
156 BEAST_EXPECT(*lv == -1);
168BEAST_DEFINE_TESTSUITE(Coroutine, core,
ripple);
testcase_t testcase
Memberspace for declaring test cases.
virtual JobQueue & getJobQueue()=0
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 wait_for(std::chrono::duration< Rep, Period > const &rel_time)
std::condition_variable cv_
void thread_specific_storage()
void run() override
Runs the suite.
A transaction testing environment.
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.