Skip to content

Commit

Permalink
Bypass clang thread_local error. (#2016)
Browse files Browse the repository at this point in the history
  • Loading branch information
hwc0919 authored Apr 29, 2024
1 parent e79d517 commit 439ddd8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/tests/unittests/CoroutineTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 439ddd8

Please sign in to comment.