Bypass clang thread_local error. (#2016)

This commit is contained in:
Nitromelon 2024-04-29 11:32:30 +08:00 committed by GitHub
parent e79d5170b4
commit 439ddd8dbe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 5 deletions

View File

@ -198,16 +198,16 @@ DROGON_TEST(AsyncWaitLifetime)
DROGON_TEST(SwitchThread)
{
thread_local int num{0};
trantor::EventLoopThread thread;
thread.getLoop()->setIndex(12345);
thread.run();
thread.getLoop()->queueInLoop([]() { num = 100; });
auto switch_thread = [TEST_CTX, &thread]() -> Task<> {
CHECK(num == 0);
co_await switchThreadCoro(thread.getLoop());
CHECK(num == 100);
thread.getLoop()->quit();
auto currentLoop = trantor::EventLoop::getEventLoopOfCurrentThread();
MANDATE(currentLoop != nullptr);
CHECK(currentLoop->index() == 12345);
currentLoop->quit();
};
sync_wait(switch_thread());
thread.wait();