no message

This commit is contained in:
cpdl
2025-05-07 16:01:31 +08:00
parent 1af1ecfbb9
commit 114980dab0
2 changed files with 24 additions and 23 deletions

View File

@@ -14,13 +14,6 @@ namespace ThreadUtil {
static std::condition_variable g_queueCondition;
static bool g_initialized = false;
static HANDLE g_workerThread = NULL;
// Function to initialize the platform thread ID
void InitializePlatformThreadId() {
g_platformThreadId = GetCurrentThreadId();
g_initialized = true;
}
// Worker thread function
unsigned __stdcall WorkerThreadProc(void* param) {
while (true) {
@@ -39,6 +32,16 @@ namespace ThreadUtil {
return 0;
}
// Function to initialize the platform thread ID
void InitializePlatformThreadId() {
g_platformThreadId = GetCurrentThreadId();
// Create worker thread
g_workerThread = (HANDLE)_beginthreadex(NULL, 0, WorkerThreadProc, NULL, 0, NULL);
g_initialized = true;
}
// Function to ensure code runs on the platform thread
void RunOnPlatformThread(std::function<void()> callback) {
@@ -46,8 +49,7 @@ namespace ThreadUtil {
if (!g_initialized) {
InitializePlatformThreadId();
// Create worker thread
g_workerThread = (HANDLE)_beginthreadex(NULL, 0, WorkerThreadProc, NULL, 0, NULL);
}
// If we're already on the platform thread, execute directly