mirror of
https://github.com/bkryza/clang-uml.git
synced 2025-04-20 14:33:48 +08:00
Updated coroutine test case with local class (#384)
This commit is contained in:
parent
32ab85a6c4
commit
66038482f5
@ -4,21 +4,22 @@
|
||||
#include <thread>
|
||||
|
||||
namespace clanguml::t20071 {
|
||||
struct awaitable_on_thread {
|
||||
std::thread *p_out;
|
||||
bool await_ready() { return false; }
|
||||
void await_suspend(std::coroutine_handle<> h)
|
||||
{
|
||||
auto &out = *p_out;
|
||||
if (out.joinable())
|
||||
throw std::runtime_error("Output thread parameter not empty");
|
||||
out = std::thread([h] { h.resume(); });
|
||||
}
|
||||
void await_resume() { }
|
||||
};
|
||||
|
||||
auto switch_to_new_thread(std::thread &out)
|
||||
{
|
||||
struct awaitable_on_thread {
|
||||
std::thread *p_out;
|
||||
bool await_ready() { return false; }
|
||||
void await_suspend(std::coroutine_handle<> h)
|
||||
{
|
||||
auto &out = *p_out;
|
||||
if (out.joinable())
|
||||
throw std::runtime_error("Output thread parameter not empty");
|
||||
out = std::thread([h] { h.resume(); });
|
||||
}
|
||||
void await_resume() { }
|
||||
};
|
||||
|
||||
return awaitable_on_thread{&out};
|
||||
}
|
||||
|
||||
|
@ -34,15 +34,15 @@ TEST_CASE("t20071")
|
||||
{"t20071.cc", "t20071.cc",
|
||||
"switch_to_new_thread(std::thread &)"}, //
|
||||
#if LLVM_VERSION_MAJOR == 14 || LLVM_VERSION_MAJOR == 15
|
||||
{"t20071.cc", "t20071.cc",
|
||||
"struct clanguml::t20071::awaitable_on_thread",
|
||||
{"t20071.cc", "t20071.cc", "struct awaitable_on_thread",
|
||||
Response{}}, //
|
||||
#else
|
||||
{"t20071.cc", "t20071.cc", "awaitable_on_thread",
|
||||
Response{}}, //
|
||||
#endif
|
||||
{"t20071.cc", "awaitable_on_thread", "await_resume()",
|
||||
CoAwait{}} //
|
||||
{"t20071.cc",
|
||||
"switch_to_new_thread(std::thread &)::awaitable_on_thread",
|
||||
"await_resume()", CoAwait{}} //
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user