Bypass clang thread_local error. (#2016)
This commit is contained in:
parent
e79d5170b4
commit
439ddd8dbe
|
@ -198,16 +198,16 @@ DROGON_TEST(AsyncWaitLifetime)
|
||||||
|
|
||||||
DROGON_TEST(SwitchThread)
|
DROGON_TEST(SwitchThread)
|
||||||
{
|
{
|
||||||
thread_local int num{0};
|
|
||||||
trantor::EventLoopThread thread;
|
trantor::EventLoopThread thread;
|
||||||
|
thread.getLoop()->setIndex(12345);
|
||||||
thread.run();
|
thread.run();
|
||||||
thread.getLoop()->queueInLoop([]() { num = 100; });
|
|
||||||
|
|
||||||
auto switch_thread = [TEST_CTX, &thread]() -> Task<> {
|
auto switch_thread = [TEST_CTX, &thread]() -> Task<> {
|
||||||
CHECK(num == 0);
|
|
||||||
co_await switchThreadCoro(thread.getLoop());
|
co_await switchThreadCoro(thread.getLoop());
|
||||||
CHECK(num == 100);
|
auto currentLoop = trantor::EventLoop::getEventLoopOfCurrentThread();
|
||||||
thread.getLoop()->quit();
|
MANDATE(currentLoop != nullptr);
|
||||||
|
CHECK(currentLoop->index() == 12345);
|
||||||
|
currentLoop->quit();
|
||||||
};
|
};
|
||||||
sync_wait(switch_thread());
|
sync_wait(switch_thread());
|
||||||
thread.wait();
|
thread.wait();
|
||||||
|
|
Loading…
Reference in New Issue