Develop: 新增IS_AUDIO_THREAD宏

This commit is contained in:
Nanako 2024-07-30 20:50:48 +08:00
parent d09302dab2
commit 400861ba0f
2 changed files with 11 additions and 0 deletions

View File

@ -5,3 +5,6 @@
thread_message_hub g_main_thread_hub;
thread_message_hub g_audio_thread_hub;
std::thread::id g_main_thread_id = std::this_thread::get_id();
std::thread::id g_audio_thread_id;

View File

@ -1,7 +1,15 @@
#pragma once
#include <thread>
#include "thread_message_hub.h"
CORE_API extern thread_message_hub g_main_thread_hub;
CORE_API extern thread_message_hub g_audio_thread_hub;
CORE_API extern std::thread::id g_main_thread_id;
CORE_API extern std::thread::id g_audio_thread_id;
#define PUSH_MAIN_THREAD(code) g_main_thread_hub.push_message(code);
#define IS_MAIN_THREAD() (std::this_thread::get_id() == g_main_thread_id)
#define IS_AUDIO_THREAD() (std::this_thread::get_id() == g_audio_thread_id)