Skip to content

Commit d4126d3

Browse files
Bug, 解决ThreadTaskRunner刚创建立即投递消息可能导致假死
1 parent ef7d1a3 commit d4126d3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/YY/Base/Threading/ThreadTaskRunnerImpl.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ namespace YY
6565
if (uThreadId == 0u)
6666
{
6767
const uint32_t uThreadIdNone = 0;
68-
Sync::WaitOnAddress(&uThreadId, (void*)(&uThreadIdNone), sizeof(uThreadIdNone), 10);
68+
Sync::WaitOnAddress(&uThreadId, (void*)(&uThreadIdNone), sizeof(uThreadIdNone), 100);
6969
}
7070
return uThreadId;
7171
}
@@ -345,6 +345,10 @@ namespace YY
345345

346346
void __YYAPI ThreadTaskRunnerImpl::operator()()
347347
{
348+
#if defined(_WIN32)
349+
// uThreadId设置前,保证消息队列被创建。避免 PostAppMessageW 没有消息队列而失败。
350+
GetQueueStatus(QS_ALLINPUT);
351+
#endif
348352
uThreadId = GetCurrentThreadId();
349353
Sync::WakeByAddressAll(const_cast<uint32_t*>(&uThreadId));
350354
g_pTaskRunnerWeak = this;

0 commit comments

Comments
 (0)