22#include <xrpld/core/JobQueue.h>
43 template <
class Rep,
class Period>
65 using namespace std::chrono_literals;
71 cfg->FORCE_MULTI_THREAD =
true;
78 jtCLIENT,
"Coroutine-Test", [&](
auto const& cr) {
93 using namespace std::chrono_literals;
99 cfg->FORCE_MULTI_THREAD =
true;
105 jtCLIENT,
"Coroutine-Test", [&](
auto const& c) {
116 using namespace std::chrono_literals;
119 testcase(
"thread specific storage");
124 static int const N = 4;
128 BEAST_EXPECT(*lv == -1);
131 jq.addJob(
jtCLIENT,
"LocalValue-Test", [&]() {
132 this->BEAST_EXPECT(*lv == -1);
134 this->BEAST_EXPECT(*lv == -2);
138 BEAST_EXPECT(*lv == -1);
140 for (
int i = 0; i < N; ++i)
142 jq.postCoro(
jtCLIENT,
"Coroutine-Test", [&,
id = i](
auto const& c) {
147 this->BEAST_EXPECT(*lv == -1);
149 this->BEAST_EXPECT(*lv ==
id);
153 this->BEAST_EXPECT(*lv ==
id);
158 for (
auto const& c : a)
164 for (
auto const& c : a)
170 jq.addJob(
jtCLIENT,
"LocalValue-Test", [&]() {
171 this->BEAST_EXPECT(*lv == -2);
175 BEAST_EXPECT(*lv == -1);
187BEAST_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.